Eile Mit Weile
Loading...
Searching...
No Matches
ClientNetworkManager Class Reference

Responsible for sending ClientRequests issued by the GameController to the server. More...

#include <ClientNetworkManager.hpp>

Static Public Member Functions

static void Init (const std::string &host, const uint16_t port)
 
static void SendRequest (const ClientRequest &request)
 
static void ParseResponse (const std::string &message)
 

Static Private Member Functions

static bool Connect (const std::string &host, const uint16_t port)
 

Static Private Attributes

static sockpp::tcp_connector_connection = nullptr
 
static bool _connection_success = false
 
static bool _failed_to_connect = false
 

Detailed Description

Responsible for sending ClientRequests issued by the GameController to the server.

Member Function Documentation

◆ Connect()

bool ClientNetworkManager::Connect ( const std::string &  host,
const uint16_t  port 
)
staticprivate

Establishes a connection to the server at the given host and port. Uses sockpp to establish a tcp connection to the server. If the connection is successful, it returns true, otherwise false.

◆ Init()

static void ClientNetworkManager::Init ( const std::string &  host,
const uint16_t  port 
)
static

Initializes the ClientNetworkManager. We use sockpp to establish a connection to the server. See ClientNetworkManager::Connect. Updates the connection status in the status bar (see GameWindow::SetStatus).

◆ ParseResponse()

void ClientNetworkManager::ParseResponse ( const std::string &  message)
static

Parses the given json message and updates the game state accordingly. Uses the static method ServerResponse::FromJson to construct a ServerResponse object from the given json string and calls the ServerResponse::Process method on the constructed object.

◆ SendRequest()

void ClientNetworkManager::SendRequest ( const ClientRequest request)
static

Sends the given ClientRequest to the server.

Member Data Documentation

◆ _connection

sockpp::tcp_connector * ClientNetworkManager::_connection = nullptr
staticprivate

The tcp connection to the server.

◆ _connection_success

bool ClientNetworkManager::_connection_success = false
staticprivate

True if the connection to the server was successful, otherwise false.

◆ _failed_to_connect

bool ClientNetworkManager::_failed_to_connect = false
staticprivate

True if the connection to the server failed, otherwise false.


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