This commit is contained in:
Johannes Wendel
2019-06-24 12:32:08 +02:00
4 changed files with 30 additions and 6 deletions

View File

@@ -173,7 +173,9 @@ HTTPServer* FlippRServer::build_output_server()
unsigned short port = (unsigned short) config().getInt("HTTPTimeServer.port", this->output_port);
// todo XDG_RUNTIME_DIR
SocketAddress address;
std::string runtime_dir = this->get_runtime_dir();
SocketAddress address(runtime_dir + SOCKET_NAME);
ServerSocket server_socket(address);
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
@@ -184,7 +186,8 @@ TCPServer* FlippRServer::build_input_server()
unsigned short port = (unsigned short) config().getInt("HTTPTimeServer.port", this->output_port);
//TODO adapt path
SocketAddress address;
std::string runtime_dir = this->get_runtime_dir();
SocketAddress address(runtime_dir + SOCKET_NAME);
ServerSocket server_socket(address);
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), port);
@@ -299,6 +302,14 @@ void FlippRServer::handle_help(const std::string& name, const std::string& value
stopOptionsProcessing();
help_requested = true;
}
std::string FlippRServer::get_runtime_dir()
{
std::string runtime_dir = std::getenv("XDG_RUNTIME_DIR");
if(runtime_dir == "")
{
runtime_dir = DEFAULT_RUNTIME_DIR;
}
}
}
}

View File

@@ -37,11 +37,14 @@ private:
void initialize_input_driver();
void parse_server_config_file();
std::string get_runtime_dir();
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";
int input_port;
int output_port;