#include <Lobby.hpp>
Public Member Functions | |
| Lobby (const std::string &name, const std::string &startTime, Communicator &communicator, const Client &client, int id, util::Logging &log, const messages::broadcast::MatchConfig &matchConfig) | |
| void | addSpectator (const Client &client, int id) |
| auto | reAddUser (const Client &client, int id) -> std::optional< int > |
| void | onMessage (const messages::Message &message, int id) |
| void | onLeave (int id) |
| auto | getUserInLobby () const -> int |
| auto | isMatchStarted () const -> bool |
| auto | getName () const -> std::string |
Represents a single lobby and all relevant information
| communication::Lobby::Lobby | ( | const std::string & | name, |
| const std::string & | startTime, | ||
| Communicator & | communicator, | ||
| const Client & | client, | ||
| int | id, | ||
| util::Logging & | log, | ||
| const messages::broadcast::MatchConfig & | matchConfig | ||
| ) |
CTor: Initialize the Lobby, and add the first client.
| name | the name of the lobby |
| startTime | the timestamp of the message that started the lobby |
| communicator | a reference to the communicator to send messages |
| client | the first client in the lobby |
| id | the id of the client as send by the MessageHandler |
| log | the log in which to write |
| matchConfig | the matchConfig for the lobby |
| void communication::Lobby::addSpectator | ( | const Client & | client, |
| int | id | ||
| ) |
Add another spectator to the lobby, this player is always a spectator at first.
| client | the client which should get added |
| id | the id of the player as send by the MessageHandler |
| auto communication::Lobby::getName | ( | ) | const -> std::string |
Get the name of the lobby
| auto communication::Lobby::getUserInLobby | ( | ) | const -> int |
Get the number of users in the lobby
| auto communication::Lobby::isMatchStarted | ( | ) | const -> bool |
Return if currently a game is active
| void communication::Lobby::onLeave | ( | int | id | ) |
An event that gets called when a client leaves
| id | the id of the player |
| void communication::Lobby::onMessage | ( | const messages::Message & | message, |
| int | id | ||
| ) |
Function that gets called on a new message (except JoinRequest which are handled in the Communicator)
| auto communication::Lobby::reAddUser | ( | const Client & | client, |
| int | id | ||
| ) | -> std::optional< int > |
Checks if a user with the same name and password is already in the lobby
| client | the new client |
| id | the id of the new client |
1.8.6