|
group2 0.1.0
CSE 125 Group 2
|
TCP stream socket — receives client packets and echoes them back. More...
#include <Server.hpp>
Public Member Functions | |
| bool | init (const char *addr, Uint16 port) |
| Bind a TCP socket to the given address and port. | |
| void | shutdown () |
| Close the socket and release resources. | |
| void | poll () |
| Drain all pending messages for this tick. | |
| bool | isEmpty () |
| Check whether the event queue is empty. | |
| Event | dequeueEvent () |
| Remove and return the next event from the queue. | |
| bool | notifyPlayerClientId (ClientId clientId, entt::entity playerEntity) |
| Update client with new entity id. | |
| void | broadcastRegistry (const Registry ®istry) |
| Broadcast the full registry state to all clients. | |
TCP stream socket — receives client packets and echoes them back.
Call poll() every tick to drain incoming messages. Extend handleMessage() with proper packet dispatch as the game protocol grows.
| void Server::broadcastRegistry | ( | const Registry & | registry | ) |
Broadcast the full registry state to all clients.
| Event Server::dequeueEvent | ( | ) |
Remove and return the next event from the queue.
| bool Server::init | ( | const char * | addr, |
| Uint16 | port | ||
| ) |
Bind a TCP socket to the given address and port.
| addr | Hostname or IP to bind to (e.g. "127.0.0.1"). |
| port | TCP port to listen on. |
| bool Server::isEmpty | ( | ) |
Check whether the event queue is empty.
| bool Server::notifyPlayerClientId | ( | ClientId | clientId, |
| entt::entity | playerEntity | ||
| ) |
Update client with new entity id.
| void Server::poll | ( | ) |
Drain all pending messages for this tick.
| void Server::shutdown | ( | ) |
Close the socket and release resources.