-
Notifications
You must be signed in to change notification settings - Fork 0
/
users_listener.hpp
47 lines (34 loc) · 1023 Bytes
/
users_listener.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Accepts incoming connections and launches the sessions
#ifndef LISTENER_HPP
#define LISTENER_HPP
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl.hpp>
#include "logger.hpp"
#include "user_client.hpp"
namespace websocket = boost::beast::websocket;
using tcp = boost::asio::ip::tcp;
class users_listener : public std::enable_shared_from_this<users_listener>
{
tcp::acceptor acceptor_;
tcp::socket socket_;
boost::asio::io_service& ios_;
boost::asio::ssl::context& ctx_;
boost::asio::io_service::strand strand_;
public:
users_listener(boost::asio::io_service& ios, boost::asio::ssl::context& ctx, tcp::endpoint endpoint);
void run();
void do_accept();
void on_accept(boost::system::error_code ec);
};
#endif