2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/vinniefalco/CppCon2018
10 #ifndef BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP
11 #define BOOST_BEAST_EXAMPLE_WEBSOCKET_CHAT_MULTI_SHARED_STATE_HPP
13 #include <boost/smart_ptr.hpp>
17 #include <unordered_set>
19 // Forward declaration
20 class websocket_session;
22 // Represents the shared server state
25 std::string const doc_root_;
27 // This mutex synchronizes all access to sessions_
30 // Keep a list of all the connected clients
31 std::unordered_set<websocket_session*> sessions_;
35 shared_state(std::string doc_root);
38 doc_root() const noexcept
43 void join (websocket_session* session);
44 void leave (websocket_session* session);
45 void send (std::string message);