|
R-Type
Distributed multiplayer game engine in C++
|
Main lobby where players connect before joining rooms. More...
#include <Lobby.hpp>

Public Member Functions | |
| Lobby (std::shared_ptr< RoomManager > roomManager) | |
| Construct a lobby. | |
| ~Lobby ()=default | |
| bool | addPlayer (uint32_t playerId, const std::string &playerName) |
| Add a player to the lobby. | |
| bool | removePlayer (uint32_t playerId) |
| Remove a player from the lobby. | |
| bool | updatePlayerName (uint32_t playerId, const std::string &newName) |
| Update a player's display name. | |
| const LobbyPlayer * | getPlayer (uint32_t playerId) const |
| Get player info. | |
| std::vector< LobbyPlayer > | getAllPlayers () const |
| Get all players in lobby. | |
| size_t | getPlayerCount () const |
| Get number of players in lobby. | |
| bool | startMatchmaking (uint32_t playerId) |
| Start matchmaking for a player. | |
| bool | cancelMatchmaking (uint32_t playerId) |
| Cancel matchmaking for a player. | |
| bool | joinRoom (uint32_t playerId, const std::string &roomId) |
| Join a specific room by ID. | |
| std::string | createCustomRoom (uint32_t hostPlayerId, const std::string &roomName, size_t maxPlayers, bool isPrivate) |
| Create a custom room. | |
| void | setPlayerReady (uint32_t playerId, bool ready) |
| Set player ready status (for custom rooms) | |
| std::shared_ptr< RoomManager > | getRoomManager () const |
| Get room manager. | |
Private Attributes | |
| std::unordered_map< uint32_t, LobbyPlayer > | _players |
| std::shared_ptr< RoomManager > | _roomManager |
| std::mutex | _mutex |
Static Private Attributes | |
| static std::atomic< uint64_t > | _nextRoomId {1} |
Main lobby where players connect before joining rooms.
Features:
|
explicit |
|
default |
| bool server::Lobby::addPlayer | ( | uint32_t | playerId, |
| const std::string & | playerName | ||
| ) |
Add a player to the lobby.
| playerId | Player ID |
| playerName | Player display name |
Definition at line 21 of file Lobby.cpp.
References _mutex, _players, server::LobbyPlayer::inMatchmaking, server::LobbyPlayer::isReady, LOG_INFO, LOG_WARNING, server::LobbyPlayer::playerId, and server::LobbyPlayer::playerName.
| bool server::Lobby::cancelMatchmaking | ( | uint32_t | playerId | ) |
| std::string server::Lobby::createCustomRoom | ( | uint32_t | hostPlayerId, |
| const std::string & | roomName, | ||
| size_t | maxPlayers, | ||
| bool | isPrivate | ||
| ) |
Create a custom room.
| hostPlayerId | Host player ID |
| roomName | Room display name |
| maxPlayers | Maximum players |
| isPrivate | Whether room is private |
Definition at line 176 of file Lobby.cpp.
References _mutex, _nextRoomId, _players, _roomManager, LOG_ERROR, LOG_INFO, and LOG_WARNING.
| std::vector< LobbyPlayer > server::Lobby::getAllPlayers | ( | ) | const |
| const LobbyPlayer * server::Lobby::getPlayer | ( | uint32_t | playerId | ) | const |
Get player info.
| playerId | Player ID |
| size_t server::Lobby::getPlayerCount | ( | ) | const |
|
inline |
Get room manager.
Definition at line 138 of file Lobby.hpp.
References _roomManager.
| bool server::Lobby::joinRoom | ( | uint32_t | playerId, |
| const std::string & | roomId | ||
| ) |
Join a specific room by ID.
| playerId | Player ID |
| roomId | Room identifier |
Definition at line 148 of file Lobby.cpp.
References _mutex, _players, _roomManager, LOG_ERROR, LOG_INFO, and LOG_WARNING.
| bool server::Lobby::removePlayer | ( | uint32_t | playerId | ) |
| void server::Lobby::setPlayerReady | ( | uint32_t | playerId, |
| bool | ready | ||
| ) |
| bool server::Lobby::startMatchmaking | ( | uint32_t | playerId | ) |
Start matchmaking for a player.
| playerId | Player ID |
Definition at line 101 of file Lobby.cpp.
References _mutex, _players, _roomManager, LOG_ERROR, LOG_INFO, and LOG_WARNING.
| bool server::Lobby::updatePlayerName | ( | uint32_t | playerId, |
| const std::string & | newName | ||
| ) |
|
mutableprivate |
Definition at line 143 of file Lobby.hpp.
Referenced by addPlayer(), cancelMatchmaking(), createCustomRoom(), getAllPlayers(), getPlayer(), getPlayerCount(), joinRoom(), removePlayer(), setPlayerReady(), startMatchmaking(), and updatePlayerName().
|
staticprivate |
Definition at line 146 of file Lobby.hpp.
Referenced by createCustomRoom().
|
private |
Definition at line 141 of file Lobby.hpp.
Referenced by addPlayer(), cancelMatchmaking(), createCustomRoom(), getAllPlayers(), getPlayer(), getPlayerCount(), joinRoom(), removePlayer(), setPlayerReady(), startMatchmaking(), and updatePlayerName().
|
private |
Definition at line 142 of file Lobby.hpp.
Referenced by cancelMatchmaking(), createCustomRoom(), getRoomManager(), joinRoom(), removePlayer(), and startMatchmaking().