BF2MC-Matchmaker
|
Represents a client for game statistics. More...
#include <client.h>
Public Member Functions | |
Client (int socket, struct sockaddr_in address) | |
Constructor for Game Statistics Client. More... | |
~Client () | |
Destructor for Game Statistics Client. | |
void | Listen () |
Start listening for client requests. More... | |
void | Disconnect () |
Disconnect the client. More... | |
void | onRequest (const std::string &request) |
Handle incoming requests from the client. More... | |
void | requestChallenge () |
Request a challenge from the client. More... | |
void | requestAuth (const GameSpy::Parameter ¶meter) |
Request authentication with provided parameters. More... | |
void | requestNewGame (const GameSpy::Parameter ¶meter) |
Request to create a new game with provided parameters. More... | |
void | requestUpdateGame (const GameSpy::Parameter ¶meter) |
Request to update an existing game with provided parameters. More... | |
![]() | |
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... | |
Static Public Member Functions | |
static void | Heartbeat () |
Heartbeat function to manage client connections. More... | |
static std::vector< unsigned char > | Encrypt (const std::string &response) |
Encrypts a response message. More... | |
static std::string | Decrypt (const std::vector< unsigned char > &request) |
Decrypts a request message. More... | |
static void | Test () |
Private Member Functions | |
void | _LogTransaction (const std::string &direction, const std::string &response) const |
Log a transaction with direction and response. More... | |
bool | _GetKeyAndPlayerIndex (const std::string &input, std::string &key, int &player_index) |
Get the key and the player index from string input. More... | |
Additional Inherited Members | |
![]() | |
int | _socket |
struct sockaddr_in | _address |
std::chrono::system_clock::time_point | _recieved_time |
std::mutex | _mutex |
Represents a client for game statistics.
This class extends the Net::Socket class to handle client connections and requests for game statistics.
Definition at line 15 of file gamestats/client.h.
GameStats::Client::Client | ( | int | socket, |
struct sockaddr_in | address | ||
) |
Constructor for Game Statistics Client.
socket | The socket ID. |
address | The client's address. |
Definition at line 27 of file gamestats/client.cpp.
|
private |
Get the key and the player index from string input.
input | The input to extract the key and player index. |
key | The key to return |
player_index | The player_index to return |
Definition at line 336 of file gamestats/client.cpp.
|
private |
Log a transaction with direction and response.
This function logs a transaction with the specified direction (e.g., "<--" or "-->") and the response received.
direction | The direction of the transaction ("<--" or "-->"). |
response | The response data to be logged. |
Definition at line 320 of file gamestats/client.cpp.
|
static |
Decrypts a request message.
This static function decrypts a received request message. It takes a vector of unsigned chars (encrypted message) and returns the decrypted message as a string.
request | The encrypted request message to decrypt. |
Definition at line 386 of file gamestats/client.cpp.
void GameStats::Client::Disconnect | ( | ) |
Disconnect the client.
This function disconnects the client from the server. It closes the socket connection and cleans up resources.
Definition at line 98 of file gamestats/client.cpp.
|
static |
Encrypts a response message.
This static function encrypts a response message before sending it over the network. It takes a string message and returns the encrypted message as a vector of unsigned chars.
response | The response message to encrypt. |
Definition at line 406 of file gamestats/client.cpp.
|
static |
Heartbeat function to manage client connections.
This function periodically checks for client connections and closes connections that have not sent any data in the last minute.
Definition at line 362 of file gamestats/client.cpp.
void GameStats::Client::Listen | ( | ) |
Start listening for client requests.
This function starts listening for incoming requests from the client. It is typically called after the client has been initialized.
Definition at line 39 of file gamestats/client.cpp.
void GameStats::Client::onRequest | ( | const std::string & | request | ) |
Handle incoming requests from the client.
This function is called to process incoming requests from the client.
request | The incoming request data. |
Definition at line 107 of file gamestats/client.cpp.
void GameStats::Client::requestAuth | ( | const GameSpy::Parameter & | parameter | ) |
Request authentication with provided parameters.
This function sends a response to the client for authentication with the provided parameters.
parameter | The authentication parameters. |
Definition at line 161 of file gamestats/client.cpp.
void GameStats::Client::requestChallenge | ( | ) |
Request a challenge from the client.
This function sends a response to the client to provide a challenge for authentication purposes.
Definition at line 136 of file gamestats/client.cpp.
void GameStats::Client::requestNewGame | ( | const GameSpy::Parameter & | parameter | ) |
Request to create a new game with provided parameters.
This function sends a request to the client to create a new game with the provided parameters.
parameter | The parameters for creating a new game. |
Definition at line 183 of file gamestats/client.cpp.
void GameStats::Client::requestUpdateGame | ( | const GameSpy::Parameter & | parameter | ) |
Request to update an existing game with provided parameters.
This function sends a response to the client to update an existing game with the provided parameters.
parameter | The parameters for updating an existing game. |
Definition at line 205 of file gamestats/client.cpp.