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

TCP stream client — sends input to the server and receives state updates. More...

#include <Client.hpp>

Public Types

using LocalPlayerReadyFn = std::function< void(entt::entity localEntity)>
 

Public Member Functions

bool init (const char *addr, Uint16 port)
 Create the TCP socket and connect to the server.
 
void shutdown ()
 Close the socket and release the resolved address.
 
bool send (const void *data, uint32_t size)
 Send a raw message to the server.
 
bool sendInputSnapshot (const InputSnapshot &snap)
 
void onLocalPlayerReady (LocalPlayerReadyFn fn)
 
bool poll (Registry &registry)
 Receive and process one pending message.
 

Detailed Description

TCP stream client — sends input to the server and receives state updates.

Member Typedef Documentation

◆ LocalPlayerReadyFn

using Client::LocalPlayerReadyFn = std::function<void(entt::entity localEntity)>

Member Function Documentation

◆ init()

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

Create the TCP socket and connect to the server.

Parameters
addrHostname or IP address of the server.
portTCP port the server is listening on.
Returns
False on socket creation or DNS failure.
Here is the caller graph for this function:

◆ onLocalPlayerReady()

void Client::onLocalPlayerReady ( LocalPlayerReadyFn  fn)
inline
Here is the caller graph for this function:

◆ poll()

bool Client::poll ( Registry registry)

Receive and process one pending message.

Returns
True if a message was received, false if the queue is empty.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send()

bool Client::send ( const void *  data,
uint32_t  size 
)

Send a raw message to the server.

Parameters
dataPointer to the payload bytes.
sizePayload length in bytes.
Returns
False if the send fails.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendInputSnapshot()

bool Client::sendInputSnapshot ( const InputSnapshot snap)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown()

void Client::shutdown ( )

Close the socket and release the resolved address.

Here is the caller graph for this function:

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