From 7a69fda894cebbbc3694baa1a10506c00de44f34 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 16 Jan 2018 23:54:37 +0100 Subject: Move SocketListener details out of header --- src/server/SocketListener.cpp | 26 ++++++++++++++++++++++---- src/server/SocketListener.hpp | 24 ++++-------------------- 2 files changed, 26 insertions(+), 24 deletions(-) (limited to 'src') 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 thread; -- cgit v1.2.1