diff options
author | David Robillard <d@drobilla.net> | 2018-01-16 23:54:37 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-01-16 23:54:37 +0100 |
commit | 7a69fda894cebbbc3694baa1a10506c00de44f34 (patch) | |
tree | 9cbcf93c1dca453d7fe681d7fa36ce97dbc5f5dc /src/server | |
parent | 1c2b3d3e3740c25df4df0a87c3a74506dc49b78c (diff) | |
download | ingen-7a69fda894cebbbc3694baa1a10506c00de44f34.tar.gz ingen-7a69fda894cebbbc3694baa1a10506c00de44f34.tar.bz2 ingen-7a69fda894cebbbc3694baa1a10506c00de44f34.zip |
Move SocketListener details out of header
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/SocketListener.cpp | 26 | ||||
-rw-r--r-- | src/server/SocketListener.hpp | 24 |
2 files changed, 26 insertions, 24 deletions
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp index 82f88ae5..e62b822e 100644 --- a/src/server/SocketListener.cpp +++ b/src/server/SocketListener.cpp @@ -39,6 +39,8 @@ namespace Ingen { namespace Server { +static constexpr const char* const unix_scheme = "unix://"; + static std::string get_link_target(const char* link_path) { @@ -59,10 +61,26 @@ get_link_target(const char* link_path) return std::string(); } -void -SocketListener::ingen_listen(Engine* engine, - Raul::Socket* unix_sock, - Raul::Socket* net_sock) +static void ingen_listen(Engine* engine, + Raul::Socket* unix_sock, + Raul::Socket* net_sock); + + +SocketListener::SocketListener(Engine& engine) + : unix_sock(Raul::Socket::Type::UNIX) + , net_sock(Raul::Socket::Type::TCP) + , thread(new std::thread(ingen_listen, &engine, &unix_sock, &net_sock)) +{} + +SocketListener::~SocketListener() { + unix_sock.shutdown(); + net_sock.shutdown(); + thread->join(); + unlink(unix_sock.uri().substr(strlen(unix_scheme)).c_str()); +} + +static void +ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) { Ingen::World* world = engine->world(); diff --git a/src/server/SocketListener.hpp b/src/server/SocketListener.hpp index 71c60d01..e74629ad 100644 --- a/src/server/SocketListener.hpp +++ b/src/server/SocketListener.hpp @@ -19,35 +19,19 @@ #include "raul/Socket.hpp" -#include "Engine.hpp" - namespace Ingen { namespace Server { +class Engine; + /** Listens on main sockets and spawns socket servers for new connections. */ class SocketListener { public: - SocketListener(Engine& engine) - : unix_sock(Raul::Socket::Type::UNIX) - , net_sock(Raul::Socket::Type::TCP) - , thread(new std::thread(ingen_listen, &engine, &unix_sock, &net_sock)) - {} - - ~SocketListener() { - unix_sock.shutdown(); - net_sock.shutdown(); - thread->join(); - unlink(unix_sock.uri().substr(strlen(unix_scheme)).c_str()); - } + SocketListener(Engine& engine); + ~SocketListener(); private: - static constexpr const char* unix_scheme = "unix://"; - - static void ingen_listen(Engine* engine, - Raul::Socket* unix_sock, - Raul::Socket* net_sock); - Raul::Socket unix_sock; Raul::Socket net_sock; std::unique_ptr<std::thread> thread; |