BF2MC-Matchmaker
Public Member Functions | Private Member Functions | List of all members
QR::Client Class Reference

Represents a client for QR protocol. More...

#include <client.h>

Inheritance diagram for QR::Client:
Inheritance graph
[legend]
Collaboration diagram for QR::Client:
Collaboration graph
[legend]

Public Member Functions

 Client (int socket, struct sockaddr_in address)
 Constructor for Client. More...
 
 ~Client ()
 Destructor for Client.
 
void onRequest (const std::vector< unsigned char > &request)
 Event handler for incoming requests. More...
 
void requestChallenge (const std::vector< unsigned char > &request) const
 Sends a request for challenge to the client. More...
 
void requestAvailable (const std::vector< unsigned char > &request) const
 Sends a request for available servers to the client. More...
 
void requestHeartbeat (const std::vector< unsigned char > &request) const
 Sends a heartbeat request to the client. More...
 
void requestKeepAlive (const std::vector< unsigned char > &request) const
 Sends a keep-alive request to the client. More...
 
- Public Member Functions inherited from Net::Socket
void Close ()
 Closes the socket.
 
std::string GetIP () const
 Gets the IP address associated with the socket. More...
 
void GetIpArray (uint8_t *ip) const
 Gets the IP address associated with the socket as an array of bytes. More...
 
uint16_t GetPort () const
 Gets the port number associated with the socket. More...
 
std::string GetAddress () const
 Gets the full address (IP:Port) associated with the socket. More...
 
std::string GetSocketType () const
 Gets the socket type. More...
 
std::chrono::system_clock::time_point GetLastRecievedTime () const
 Gets the time when the socket last received data. More...
 
void Send (const std::string &msg) const
 Sends a message over the socket. More...
 
void Send (const std::vector< unsigned char > &msg) const
 Sends a message over the socket. More...
 
void UDPSend (const std::string &msg) const
 Sends a UDP message over the socket. More...
 
void UDPSend (const std::vector< unsigned char > &msg) const
 Sends a UDP message over the socket. More...
 
void UpdateLastRecievedTime ()
 Updates the last received time to the current system time.
 
virtual void WTF_WHY_AM_I_HERE_1337 ()
 Empty virtual function required for static_cast in C++. More...
 

Private Member Functions

void _LogTransaction (const std::string &direction, const std::string &response) const
 Logs a transaction with direction and response. More...
 

Additional Inherited Members

- Protected Attributes inherited from Net::Socket
int _socket
 
struct sockaddr_in _address
 
std::chrono::system_clock::time_point _recieved_time
 
std::mutex _mutex
 

Detailed Description

Represents a client for QR protocol.

Definition at line 12 of file qr/client.h.

Constructor & Destructor Documentation

◆ Client()

QR::Client::Client ( int  socket,
struct sockaddr_in  address 
)

Constructor for Client.

Parameters
socketThe socket of the client.
addressThe address information of the client.

Definition at line 24 of file qr/client.cpp.

Member Function Documentation

◆ _LogTransaction()

void QR::Client::_LogTransaction ( const std::string &  direction,
const std::string &  response 
) const
private

Logs a transaction with direction and response.

Parameters
directionThe direction of the transaction ("<--" or "-->").
responseThe response message to log.

Definition at line 294 of file qr/client.cpp.

◆ onRequest()

void QR::Client::onRequest ( const std::vector< unsigned char > &  request)

Event handler for incoming requests.

Parameters
requestThe incoming request data.

Definition at line 37 of file qr/client.cpp.

◆ requestAvailable()

void QR::Client::requestAvailable ( const std::vector< unsigned char > &  request) const

Sends a request for available servers to the client.

Parameters
requestThe available servers request data.

Definition at line 72 of file qr/client.cpp.

◆ requestChallenge()

void QR::Client::requestChallenge ( const std::vector< unsigned char > &  request) const

Sends a request for challenge to the client.

Parameters
requestThe challenge request data.

Definition at line 59 of file qr/client.cpp.

◆ requestHeartbeat()

void QR::Client::requestHeartbeat ( const std::vector< unsigned char > &  request) const

Sends a heartbeat request to the client.

Parameters
requestThe heartbeat request data.

Definition at line 137 of file qr/client.cpp.

◆ requestKeepAlive()

void QR::Client::requestKeepAlive ( const std::vector< unsigned char > &  request) const

Sends a keep-alive request to the client.

Parameters
requestThe keep-alive request data.

Definition at line 278 of file qr/client.cpp.


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