aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/server.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-11-30 01:38:08 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-12-01 05:23:11 +0300
commit90bd600c5025ede4db99122f13dfb07b27de46ae (patch)
tree0b581b43e5fcb54114c6c373352ed6ab5fcd61dc /server/server.hpp
downloadmath-server-90bd600c5025ede4db99122f13dfb07b27de46ae.tar.gz
math-server-90bd600c5025ede4db99122f13dfb07b27de46ae.zip
initial commit
Diffstat (limited to 'server/server.hpp')
-rw-r--r--server/server.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/server.hpp b/server/server.hpp
new file mode 100644
index 0000000..5524f88
--- /dev/null
+++ b/server/server.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "session_manager.hpp"
+#include "settings.hpp"
+
+#include <boost/asio.hpp>
+#include <boost/system/error_code.hpp>
+
+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;
+};
+
+}