3#include <StormByte/network/endpoint.hxx>
4#include <StormByte/network/typedefs.hxx>
8#include <unordered_map>
23 Server(Connection::Protocol protocol, std::shared_ptr<Connection::Handler> handler, std::shared_ptr<Logger> logger)
noexcept;
62 virtual StormByte::Expected<
void,
ConnectionError> Start(const std::
string& host, const
unsigned short& port) noexcept;
67 virtual
void Stop() noexcept;
84 void RemoveClient(Socket::
Client& client) noexcept;
90 void RemoveClientAsync(Socket::
Client& client) noexcept;
96 void DisconnectClient(Socket::
Client& client) noexcept;
102 virtual
bool Handshake(Socket::
Client& client) noexcept;
113 std::thread m_accept_thread;
114 std::mutex m_clients_mutex;
115 std::vector<Socket::
Client> m_clients;
116 std::mutex m_msg_threads_mutex;
117 std::unordered_map<
Connection::Handler::Type, std::thread> m_msg_threads;
122 void DisconnectAllClients() noexcept;
127 void AcceptClients() noexcept;
133 void StartClientCommunication(Socket::
Client& client) noexcept;
139 void HandleClientMessages(Socket::
Client& client) noexcept;
The class representing a client.
Definition client.hxx:15
The class representing an error in the connection.
Definition exception.hxx:27
Represents a network endpoint, serving as a base class for both clients and servers.
Definition endpoint.hxx:17
A server class.
Definition server.hxx:16
Server(Server &&other) noexcept=default
Move constructor.
virtual ~Server() noexcept override
Destructor.
Server(Connection::Protocol protocol, std::shared_ptr< Connection::Handler > handler, std::shared_ptr< Logger > logger) noexcept
Constructor.
Server(const Server &other)=delete
Copy constructor (deleted).
The namespace containing connection items.
Contains all the network-related classes and utilities.
Definition client.hxx:10
std::future< Buffer::Simple > FutureBuffer
The future data type.
Definition typedefs.hxx:26
std::function< StormByte::Expected< FutureBuffer, ConnectionError >(Socket::Client &, FutureBuffer &)> FutureBufferProcessor
The future data function type.
Definition typedefs.hxx:34
StormByte::Expected< FutureBuffer, ConnectionError > ExpectedFutureBuffer
The expected future type.
Definition typedefs.hxx:29
StormByte::Expected< void, ConnectionError > ExpectedVoid
The expected void type.
Definition typedefs.hxx:30