added inputsockethandlerfactory
This commit is contained in:
@@ -6,12 +6,14 @@ set(SOURCES
|
||||
input/InputSocketHandler.cpp
|
||||
output/OutputRequestHandler.cpp
|
||||
output/OutputRequestHandlerFactory.cpp
|
||||
FlippRServer.cpp)
|
||||
FlippRServer.cpp
|
||||
input/InputSocketHandlerFactory.cpp)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE FlippR-Driver)
|
||||
|
||||
####################### POCO ##############################
|
||||
|
||||
@@ -99,8 +99,8 @@ void FlippRServer::initialize_output_driver()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//todo should use DriverFactory from input
|
||||
// this->input_driver = flippR_driver::get_InputDriver(input_config_stream, matrix_config_stream);
|
||||
//todo linking errors
|
||||
this->input_driver = flippR_driver::get_InputDriver(input_config_stream, matrix_config_stream);
|
||||
}
|
||||
|
||||
int FlippRServer::main(const std::vector<std::string>& args)
|
||||
@@ -111,7 +111,7 @@ int FlippRServer::main(const std::vector<std::string>& args)
|
||||
std::unique_ptr<HTTPServer> output_server(this->build_output_server());
|
||||
output_server->start();
|
||||
|
||||
std::unique_ptr<TCPServer>
|
||||
std::unique_ptr<TCPServer> input_server(this->build_input_server());
|
||||
|
||||
waitForTerminationRequest();
|
||||
this->output_driver->deactivate_all_lamps();
|
||||
@@ -127,9 +127,20 @@ HTTPServer* FlippRServer::build_output_server()
|
||||
|
||||
// todo XDG_RUNTIME_DIR
|
||||
SocketAddress address("/tmp/flippR_driver/S.flippR_driver");
|
||||
ServerSocket svs(address);
|
||||
ServerSocket server_socket(address);
|
||||
|
||||
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
|
||||
}
|
||||
|
||||
TCPServer* FlippRServer::build_input_server()
|
||||
{
|
||||
unsigned short port = (unsigned short) config().getInt("HTTPTimeServer.port", this->output_port);
|
||||
|
||||
//TODO adapt path
|
||||
SocketAddress address("/tmp/flippR_driver/S.flippR_driver");
|
||||
ServerSocket server_socket(address);
|
||||
|
||||
|
||||
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), svs, new HTTPServerParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
void parse_server_config_file();
|
||||
|
||||
Poco::Net::HTTPServer* build_output_server();
|
||||
Poco::Net::TCPServer* build_input_server();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
31
FlippR-Driver/networking/input/InputSocketHandlerFactory.cpp
Normal file
31
FlippR-Driver/networking/input/InputSocketHandlerFactory.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by johannes on 15.06.19.
|
||||
//
|
||||
|
||||
#include "InputSocketHandlerFactory.h"
|
||||
|
||||
#include "InputSocketHandler.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace networking
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
using namespace Poco::Net;
|
||||
|
||||
InputSocketHandlerFactory::InputSocketHandlerFactory(std::shared_ptr<flippR_driver::input::InputDriver> inputDriver) :
|
||||
input_driver(inputDriver)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TCPServerConnection *InputSocketHandlerFactory::createConnection(const Poco::Net::StreamSocket &socket)
|
||||
{
|
||||
return new InputSocketHandler(socket, this->input_driver);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
FlippR-Driver/networking/input/InputSocketHandlerFactory.h
Normal file
33
FlippR-Driver/networking/input/InputSocketHandlerFactory.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by johannes on 15.06.19.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H
|
||||
#define FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H
|
||||
|
||||
#include <Poco/Net/TCPServerConnectionFactory.h>
|
||||
#include <input/InputDriver.h>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace networking
|
||||
{
|
||||
namespace input
|
||||
{
|
||||
|
||||
class InputSocketHandlerFactory : Poco::Net::TCPServerConnectionFactory
|
||||
{
|
||||
public:
|
||||
explicit InputSocketHandlerFactory(std::shared_ptr<flippR_driver::input::InputDriver> inputDriver);
|
||||
|
||||
Poco::Net::TCPServerConnection* createConnection(const Poco::Net::StreamSocket &socket) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<flippR_driver::input::InputDriver> input_driver;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
namespace networking
|
||||
{
|
||||
using namespace Poco::Net;
|
||||
|
||||
OutputHTTPServer::OutputHTTPServer(std::shared_ptr<output::OutputDriver> output_driver, Socket &socket) :
|
||||
HTTPServer(new OutputRequestHandlerFactory(output_driver), socket, new HTTPServerParams())
|
||||
HTTPServer(new OutputRequestHandlerFactory(output_driver), socket, new HTTPServerParams())
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace utility
|
||||
namespace networking
|
||||
{
|
||||
|
||||
class OutputHTTPServer : public Poco::Net::HTTPServer
|
||||
|
||||
Reference in New Issue
Block a user