From 00863566ec4601c65c435b74e575d49546a1c707 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 7 Dec 2019 03:36:21 +0300 Subject: split server into multiple components In a vague attempt to make header files more readable, split server/ into a number of components. Also, refactor the unit tests to use the "Data-driven test cases" of Boost.Test. --- server/main/server.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 server/main/server.hpp (limited to 'server/main/server.hpp') diff --git a/server/main/server.hpp b/server/main/server.hpp new file mode 100644 index 0000000..5524f88 --- /dev/null +++ b/server/main/server.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "session_manager.hpp" +#include "settings.hpp" + +#include +#include + +namespace math::server { + +class Server { +public: + Server(const Settings& settings); + Server(unsigned port, unsigned threads); + + void run(); + +private: + void wait_for_signal(); + void handle_signal(const boost::system::error_code&, int); + + void accept(); + void handle_accept(SessionPtr session, const boost::system::error_code& ec); + + const unsigned m_numof_threads; + + boost::asio::io_context m_io_context; + boost::asio::signal_set m_signals; + boost::asio::ip::tcp::acceptor m_acceptor; + + SessionManager m_session_mgr; +}; + +} -- cgit v1.2.3