group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Server Class Reference

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 &registry)
 Broadcast the full registry state to all clients.
 

Detailed Description

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.

Member Function Documentation

◆ broadcastRegistry()

void Server::broadcastRegistry ( const Registry registry)

Broadcast the full registry state to all clients.

Here is the call graph for this function:

◆ dequeueEvent()

Event Server::dequeueEvent ( )

Remove and return the next event from the queue.

Returns
The front event.
Here is the call graph for this function:

◆ init()

bool Server::init ( const char *  addr,
Uint16  port 
)

Bind a TCP socket to the given address and port.

Parameters
addrHostname or IP to bind to (e.g. "127.0.0.1").
portTCP port to listen on.
Returns
False on DNS or socket creation failure.
Here is the caller graph for this function:

◆ isEmpty()

bool Server::isEmpty ( )

Check whether the event queue is empty.

Returns
True if no events are pending.
Here is the call graph for this function:

◆ notifyPlayerClientId()

bool Server::notifyPlayerClientId ( ClientId  clientId,
entt::entity  playerEntity 
)

Update client with new entity id.

Returns
true if sent, otherwise false.

◆ poll()

void Server::poll ( )

Drain all pending messages for this tick.

Here is the caller graph for this function:

◆ shutdown()

void Server::shutdown ( )

Close the socket and release resources.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: