18class Server :
public std::enable_shared_from_this<Server> {
25 Server(asio::io_context &io,
unsigned short port);
50 void handleMessage(std::size_t bytesReceived);
52 asio::ip::udp::socket socket_;
53 asio::ip::udp::endpoint remoteEndpoint_;
55 std::array<char, 2048> recvBuffer_;
Tracks (ip::udp::endpoint)->clientId and allows lookup in reverse.
Manages multiple Game instances and routes messages/events.
The main UDP server that accepts client messages and updates the game logic.
GameManager & getGameManager()
Accessor for the GameManager that manages multiple games.
Server(asio::io_context &io, unsigned short port)
Constructs the Server, binding a UDP socket to the specified port.
void sendToClient(uint32_t clientId, const Message &msg)
Sends a Message to a specific client by ID (uses clientManager to find endpoint).
Minimal network message with a 4-byte header (type + length) and a payload.