• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/vinniefalco/CppCon2018
8 //
9 
10 #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP
11 #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_LISTENER_HPP
12 
13 #include "beast.hpp"
14 #include "net.hpp"
15 #include <boost/smart_ptr.hpp>
16 #include <memory>
17 #include <string>
18 
19 // Forward declaration
20 class shared_state;
21 
22 // Accepts incoming connections and launches the sessions
23 class listener : public boost::enable_shared_from_this<listener>
24 {
25     net::io_context& ioc_;
26     tcp::acceptor acceptor_;
27     boost::shared_ptr<shared_state> state_;
28 
29     void fail(beast::error_code ec, char const* what);
30     void on_accept(beast::error_code ec, tcp::socket socket);
31 
32 public:
33     listener(
34         net::io_context& ioc,
35         tcp::endpoint endpoint,
36         boost::shared_ptr<shared_state> const& state);
37 
38     // Start accepting incoming connections
39     void run();
40 };
41 
42 #endif
43