BF2MC-Matchmaker
|
Public Types | |
enum | Type { QR , GPSP , GPCM , Webserver , Browsing , GameStats , Websocket , None } |
Enum defining the types of servers. More... | |
Public Member Functions | |
Server (Server::Type type) | |
Constructor for the Server class. More... | |
std::vector< std::shared_ptr< Net::Socket > > | GetClients () |
Get the vector of client sockets connected to this server. More... | |
void | Listen () |
Start listening for incoming connections on the server. | |
void | UDPListen () |
Start listening for incoming UDP packets on the server. | |
void | DisconnectAllClients () |
Disconnect all connected clients from the server. | |
void | Close () |
Close the server and stop listening for incoming connections. | |
void | onServerListen () const |
Called when the server starts listening for incoming connections. More... | |
void | onServerShutdown () const |
Called when the server is shutting down. More... | |
void | onClientConnect (const Net::Socket &client) const |
Called when a client connects to the server. More... | |
void | onClientConnect (const std::shared_ptr< Net::Socket > &client) const |
Called when a client connects to the server. More... | |
void | onClientDisconnect (const Net::Socket &client) |
Called when a client disconnects from the server. 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... | |
Private Attributes | |
std::vector< std::shared_ptr< Net::Socket > > | _clients |
Server::Type | _type |
std::mutex | _mutex |
Additional Inherited Members | |
![]() | |
int | _socket |
struct sockaddr_in | _address |
std::chrono::system_clock::time_point | _recieved_time |
std::mutex | _mutex |
enum Server::Type |
Enum defining the types of servers.
Server::Server | ( | Server::Type | type | ) |
Constructor for the Server class.
type | The type of the server. |
Definition at line 24 of file server.cpp.
std::vector< std::shared_ptr< Net::Socket > > Server::GetClients | ( | ) |
Get the vector of client sockets connected to this server.
Definition at line 86 of file server.cpp.
void Server::onClientConnect | ( | const Net::Socket & | client | ) | const |
Called when a client connects to the server.
client | The client socket that connected. |
Definition at line 314 of file server.cpp.
void Server::onClientConnect | ( | const std::shared_ptr< Net::Socket > & | client | ) | const |
Called when a client connects to the server.
client | The shared pointer to the client socket that connected. |
Definition at line 325 of file server.cpp.
void Server::onClientDisconnect | ( | const Net::Socket & | client | ) |
Called when a client disconnects from the server.
client | The client socket that disconnected. |
Definition at line 336 of file server.cpp.
void Server::onServerListen | ( | ) | const |
Called when the server starts listening for incoming connections.
This function is called when the server starts listening for incoming connections.
Definition at line 304 of file server.cpp.
void Server::onServerShutdown | ( | ) | const |
Called when the server is shutting down.
This function is called when the server is shutting down.
Definition at line 309 of file server.cpp.
|
private |
|
mutableprivate |
|
private |