27 bool Start(uint16_t port);
void SetClientName(const std::string &name)
Sets the client's display name.
ConnectCallback m_connectCallback
void SetMessageCallback(MessageCallback cb)
Sets the callback for incoming messages.
void Stop()
Stops the server and disconnects any client.
uint16_t GetPort() const
Returns the port the server is listening on.
bool Send(const Network::MessageFrame &frame)
Sends a message frame to the connected client. Returns true on success.
bool Start(uint16_t port)
Starts the server listening on the given port. Returns true on success.
void SetDisconnectCallback(DisconnectCallback cb)
Sets the callback for client disconnections.
DisconnectCallback m_disconnectCallback
std::function< void()> DisconnectCallback
Callback invoked when the client disconnects.
void DisconnectClient()
Disconnects the current client without stopping the server.
std::vector< uint8_t > m_recvBuffer
std::string GetClientName() const
Returns the client's display name.
bool IsClientConnected() const
Returns true if a client is currently connected.
bool IsRunning() const
Returns true if the server is listening.
void SetConnectCallback(ConnectCallback cb)
Sets the callback for client connections.
std::string m_clientAddress
void Poll()
Processes pending I/O (accept, read). Call periodically from the main loop.
MessageCallback m_messageCallback
std::string GetClientAddress() const
Returns the connected client's address string.
std::function< void(const Network::MessageFrame &)> MessageCallback
Callback invoked when a message is received from the client.
std::function< void(const std::string &address)> ConnectCallback
Callback invoked when a client connects.
bool SetNonBlocking(int socket)