Botball Game State
A game stared library for Botball, it helps model the table and different phases of the competition.
Loading...
Searching...
No Matches
Server Class Reference
Inheritance diagram for Server:
Socket

Public Member Functions

void init (const std::string &table_config_path, const std::string &phase_config_path, const std::string &game_state_config_path)
void validate_phase (const Phase &phase) const
json generate_response () const
GameState serve (int port)
Public Member Functions inherited from Socket
void init_socket (uint16_t port)
void init_server (uint16_t port)
void init_client (const std::string &ip_address, uint16_t port)
void recv_all (void *buf, size_t len)
void send_all (const void *buf, size_t len) const
void send_json (const json &data) const
std::optional< json > recv_json ()
void shutdown_socket ()
void close_socket ()

Additional Inherited Members

Protected Attributes inherited from Socket
int m_fd = -1
bool m_closed = true
std::shared_ptr< spdlog::logger > m_log

Member Function Documentation

◆ generate_response()

json Server::generate_response ( ) const
nodiscard

Generates the response for bot_b to reconstruct the game state locally.

◆ init()

void Server::init ( const std::string & table_config_path,
const std::string & phase_config_path,
const std::string & game_state_config_path )

Reads in all necessary values from the config, constructs PhaseState, TableState and Config object (responsible for configuring the phase selection algorithm).

Parameters
table_config_pathpath to table state config file
phase_config_pathpath to phases config file
game_state_config_pathpath to game state configuration files

◆ serve()

GameState Server::serve ( int port)
nodiscard

listens for a request from bot_b, responds with an acknowledgement, await another request and send the (in init) constructed objects to bot_b

Parameters
portto listen on

◆ validate_phase()

void Server::validate_phase ( const Phase & phase) const

Validates a phase by comparing key, value pairs against the table state.

Parameters
phaseto be validated

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