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

Client class for handling browsing requests. More...

#include <client.h>

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

Public Member Functions

 Client (int socket, struct sockaddr_in address)
 Constructs a new Client object. More...
 
 ~Client ()
 Destroys the Client object.
 
void Listen ()
 Listens for incoming requests from the client.
 
void Disconnect ()
 Disconnects the client.
 
void onRequest (const std::vector< unsigned char > &request)
 Event handler for incoming requests. More...
 
void requestServerList (const std::vector< unsigned char > &request)
 Sends a request for the server list. More...
 
void requestServerInfo (const std::vector< unsigned char > &request)
 Sends a request for server information. 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...
 

Static Public Member Functions

static void Test ()
 Testing function to encrypt/decrypt a package.
 
static void Crack ()
 Cracking function to find the secret key from a package.
 
static void Heartbeat ()
 Heartbeat function to manage client connections. More...
 

Private Member Functions

void _BufferToRequests (const std::vector< unsigned char > &buffer, std::vector< std::vector< unsigned char >> &requests)
 Converts a buffer to a list of requests. More...
 
void _insertClientInfo (std::vector< unsigned char > &response)
 Inserts client information into the response. More...
 
void _insertGameServerFlagIpPort (std::vector< unsigned char > &response, const Battlefield::GameServer &game_server)
 Inserts game server flag, IP, and port into the response. More...
 
void _Encrypt (std::vector< unsigned char > &response)
 Encrypts the response. More...
 
void _LogTransaction (const std::string &direction, const std::string &response) const
 Logs a transaction. More...
 
void _FilterServers (const std::string &filter, Battlefield::GameServers &game_servers)
 Filters game servers based on the provided filter criteria. More...
 
bool _FilterServerGameVersion (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on game version. More...
 
bool _FilterServerRegion (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on region. More...
 
bool _FilterServerNumPlayers (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on number of players. More...
 
bool _FilterServerGameType (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on game type. More...
 
bool _FilterServerMapName (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on map name. More...
 
bool _FilterServerStatsTracking (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on stats tracking. More...
 
bool _FilterServerReconfigurable (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on reconfigurability. More...
 
bool _FilterServerClan (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on clan. More...
 
bool _FilterServerTeamplay (const std::string &filter, const Battlefield::GameServer &game_server)
 Checks if a game server matches the filter criteria based on teamplay. More...
 

Private Attributes

std::vector< unsigned char > _client_challenge
 Challenge data sent to the client. 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

Client class for handling browsing requests.

Definition at line 14 of file browsing/client.h.

Constructor & Destructor Documentation

◆ Client()

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

Constructs a new Client object.

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

Definition at line 30 of file browsing/client.cpp.

Member Function Documentation

◆ _BufferToRequests()

void Browsing::Client::_BufferToRequests ( const std::vector< unsigned char > &  buffer,
std::vector< std::vector< unsigned char >> &  requests 
)
private

Converts a buffer to a list of requests.

Parameters
bufferThe buffer containing the requests.
[out]requestsThe vector to store the parsed requests.

Definition at line 530 of file browsing/client.cpp.

◆ _Encrypt()

void Browsing::Client::_Encrypt ( std::vector< unsigned char > &  response)
private

Encrypts the response.

Parameters
responseThe response to encrypt.

Definition at line 606 of file browsing/client.cpp.

◆ _FilterServerClan()

bool Browsing::Client::_FilterServerClan ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on clan.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 888 of file browsing/client.cpp.

◆ _FilterServerGameType()

bool Browsing::Client::_FilterServerGameType ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on game type.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 766 of file browsing/client.cpp.

◆ _FilterServerGameVersion()

bool Browsing::Client::_FilterServerGameVersion ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on game version.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 692 of file browsing/client.cpp.

◆ _FilterServerMapName()

bool Browsing::Client::_FilterServerMapName ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on map name.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 784 of file browsing/client.cpp.

◆ _FilterServerNumPlayers()

bool Browsing::Client::_FilterServerNumPlayers ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on number of players.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 738 of file browsing/client.cpp.

◆ _FilterServerReconfigurable()

bool Browsing::Client::_FilterServerReconfigurable ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on reconfigurability.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 820 of file browsing/client.cpp.

◆ _FilterServerRegion()

bool Browsing::Client::_FilterServerRegion ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on region.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 710 of file browsing/client.cpp.

◆ _FilterServers()

void Browsing::Client::_FilterServers ( const std::string &  filter,
Battlefield::GameServers &  game_servers 
)
private

Filters game servers based on the provided filter criteria.

Parameters
filterThe filter string.
game_serversThe list of game servers to filter.

Definition at line 664 of file browsing/client.cpp.

◆ _FilterServerStatsTracking()

bool Browsing::Client::_FilterServerStatsTracking ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on stats tracking.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 802 of file browsing/client.cpp.

◆ _FilterServerTeamplay()

bool Browsing::Client::_FilterServerTeamplay ( const std::string &  filter,
const Battlefield::GameServer game_server 
)
private

Checks if a game server matches the filter criteria based on teamplay.

Parameters
filterThe filter string.
game_serverThe game server to check.
Returns
True if the game server should be filtered out, false otherwise.

Definition at line 847 of file browsing/client.cpp.

◆ _insertClientInfo()

void Browsing::Client::_insertClientInfo ( std::vector< unsigned char > &  response)
private

Inserts client information into the response.

Parameters
responseThe response to modify.

Definition at line 553 of file browsing/client.cpp.

◆ _insertGameServerFlagIpPort()

void Browsing::Client::_insertGameServerFlagIpPort ( std::vector< unsigned char > &  response,
const Battlefield::GameServer game_server 
)
private

Inserts game server flag, IP, and port into the response.

Parameters
responseThe response to modify.
game_serverThe game server to get the information from.

Definition at line 565 of file browsing/client.cpp.

◆ _LogTransaction()

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

Logs a transaction.

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

Definition at line 648 of file browsing/client.cpp.

◆ Heartbeat()

void Browsing::Client::Heartbeat ( )
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 921 of file browsing/client.cpp.

◆ onRequest()

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

Event handler for incoming requests.

Parameters
requestThe incoming request.

Definition at line 94 of file browsing/client.cpp.

◆ requestServerInfo()

void Browsing::Client::requestServerInfo ( const std::vector< unsigned char > &  request)

Sends a request for server information.

Parameters
requestThe request data.

Definition at line 466 of file browsing/client.cpp.

◆ requestServerList()

void Browsing::Client::requestServerList ( const std::vector< unsigned char > &  request)

Sends a request for the server list.

Parameters
requestThe request data.

Definition at line 190 of file browsing/client.cpp.

Member Data Documentation

◆ _client_challenge

std::vector<unsigned char> Browsing::Client::_client_challenge
private

Challenge data sent to the client.

When a client connects to the browsing server, it receives a challenge to validate its connection.

Definition at line 23 of file browsing/client.h.


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