restructured server app
This commit is contained in:
@@ -85,6 +85,15 @@ void FlippRServer::parse_server_config_file()
|
||||
config.close();
|
||||
}
|
||||
|
||||
void FlippRServer::uninitialize()
|
||||
{
|
||||
this->output_driver->deactivate_all_lamps();
|
||||
this->output_driver->deactivate_displays();
|
||||
this->output_server->stop();
|
||||
|
||||
ServerApplication::uninitialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initially called before main.
|
||||
*/
|
||||
@@ -93,10 +102,14 @@ void FlippRServer::initialize(Application &self)
|
||||
//Todo May restructure with subsystems
|
||||
//make this one application and subsystems ServerApplications
|
||||
|
||||
|
||||
this->initialize_output_driver();
|
||||
this->initialize_input_driver();
|
||||
|
||||
this->output_server = std::unique_ptr<Poco::Net::HTTPServer>(this->build_output_server());
|
||||
this->output_server->start();
|
||||
|
||||
this->input_server = std::unique_ptr<TCPServer>(this->build_input_server());
|
||||
|
||||
//https://gist.github.com/NIPE-SYSTEMS/5a06428c0880ed7ff3cc4304be436e3e
|
||||
ServerApplication::initialize(self);
|
||||
}
|
||||
@@ -151,15 +164,8 @@ int FlippRServer::main(const std::vector<std::string>& args)
|
||||
if(help_requested)
|
||||
return Application::EXIT_OK;
|
||||
|
||||
std::unique_ptr<HTTPServer> output_server(this->build_output_server());
|
||||
output_server->start();
|
||||
|
||||
std::unique_ptr<TCPServer> input_server(this->build_input_server());
|
||||
|
||||
waitForTerminationRequest();
|
||||
this->output_driver->deactivate_all_lamps();
|
||||
this->output_driver->deactivate_displays();
|
||||
output_server->stop();
|
||||
|
||||
return Application::EXIT_OK;
|
||||
}
|
||||
@@ -187,8 +193,6 @@ TCPServer* FlippRServer::build_input_server()
|
||||
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), port);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FlippRServer::defineOptions(OptionSet& options)
|
||||
{
|
||||
ServerApplication::defineOptions(options);
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void initialize(Poco::Util::Application& self);
|
||||
void uninitialize();
|
||||
|
||||
void defineOptions(Poco::Util::OptionSet& options);
|
||||
void handle_help(const std::string &name, const std::string &port);
|
||||
@@ -38,7 +39,6 @@ private:
|
||||
Poco::Net::HTTPServer* build_output_server();
|
||||
Poco::Net::TCPServer* build_input_server();
|
||||
|
||||
|
||||
private:
|
||||
const std::string DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/";
|
||||
const std::string SOCKET_NAME = "S.flippR_driver";
|
||||
@@ -56,6 +56,10 @@ private:
|
||||
|
||||
std::shared_ptr<input::InputDriver> input_driver;
|
||||
std::shared_ptr<output::OutputDriver> output_driver;
|
||||
|
||||
std::unique_ptr<Poco::Net::HTTPServer> output_server;
|
||||
std::unique_ptr<Poco::Net::TCPServer> input_server;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user