14#include <unordered_map>
27 std::chrono::steady_clock::time_point
joinTime;
62 std::shared_ptr<server::EventBus> eventBus =
nullptr);
65 void addPlayer(uint32_t playerId)
override;
71 uint32_t playerId,
const std::vector<std::shared_ptr<Room>> &availableRooms,
72 bool allowSpectator =
true)
override;
Type-safe event publication/subscription system.
Interface for a matchmaking system.
Automatic matchmaking service.
std::vector< PlayerQueueInfo > _waitingPlayers
std::string getStatistics() const
Get statistics about matchmaking.
std::pair< std::shared_ptr< Room >, bool > findOrCreateMatch(uint32_t playerId, const std::vector< std::shared_ptr< Room > > &availableRooms, bool allowSpectator=true) override
Find an available room or add player to matchmaking queue.
void removePlayer(uint32_t playerId) override
Remove a player from the matchmaking queue.
MatchCreatedCallback _matchCreatedCallback
uint32_t _totalPlayersMatched
~MatchmakingService() override=default
void tick() override
Process matchmaking queue and create matches Called periodically by the server.
std::shared_ptr< server::EventBus > _eventBus
std::string _generateRoomId()
Generate unique room ID for a new match.
size_t getQueueSize() const override
Get the number of players waiting in queue.
uint32_t _totalMatchesCreated
bool _tryCreateMatch()
Try to create a match from waiting players.
void setMatchCreatedCallback(MatchCreatedCallback callback) override
Set callback for when a match is created.
std::vector< PlayerQueueInfo > getWaitingPlayers() const
Get list of waiting players.
void addPlayer(uint32_t playerId) override
Add a player to the matchmaking queue.
void setMaxPlayers(size_t max)
Set maximum players per match.
void setMinPlayers(size_t min)
Set minimum players required to start a match.
std::function< void(std::shared_ptr< Room >)> MatchCreatedCallback
Callback invoked when a match is created.
Information about a player in matchmaking queue.
std::chrono::steady_clock::time_point joinTime