16 #include <boost/asio/io_context.hpp> 17 #include <boost/asio/ip/tcp.hpp> 22 #include <unordered_map> 35 class Router :
public std::enable_shared_from_this<Router> {
39 explicit Router(uint16_t port);
48 void SetNewConnectionCallback(std::function<
void(
void)>);
50 void AsyncRun(
size_t worker_threads);
52 boost::asio::ip::tcp::endpoint GetLocalEndpoint()
const;
55 return (!_sessions.empty());
62 std::weak_ptr<Primary> GetNextServer();
65 void ConnectSession(std::shared_ptr<Primary>
session);
66 void DisconnectSession(std::shared_ptr<Primary> session);
76 std::unordered_map<Primary *, std::shared_ptr<std::promise<SessionInfo>>>
_promises;
boost::asio::ip::tcp::endpoint _endpoint
std::shared_ptr< Primary > session
bool HasClientsConnected()
std::function< void(void)> _callback
This file contains definitions of common data structures used in traffic manager. ...
std::unordered_map< Primary *, std::shared_ptr< std::promise< SessionInfo > > > _promises
PrimaryCommands & GetCommander()
std::shared_ptr< Listener > _listener
std::vector< std::shared_ptr< Primary > > _sessions
A thread pool based on Boost.Asio's io context.
PrimaryCommands _commander