-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameRoomManager.h
48 lines (36 loc) · 1.33 KB
/
GameRoomManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by floweryclover on 2024-01-30.
//
#ifndef BATTLEGAME_SERVER_GAMEROOMMANAGER_H
#define BATTLEGAME_SERVER_GAMEROOMMANAGER_H
#include <map>
#include <queue>
#include <optional>
#include "GameRoom.h"
using SerializedEndpoint = unsigned long long;
using ClientId = SerializedEndpoint;
using GameRoomId = unsigned int;
class GameRoomManager {
public:
explicit GameRoomManager() noexcept;
~GameRoomManager() = default;
void JoinPlayer(ClientId clientId, GameRoomId roomId);
void DestroyRoom(GameRoomId roomId) noexcept;
void StartMatchMaking(ClientId clientId);
void StopMatchMaking(ClientId clientId);
std::optional<GameRoomId> GetPlayerJoinedRoomId(ClientId clientId) const noexcept;
void OnPlayerConnected(ClientId clientId);
void OnPlayerDisconnected(ClientId clientId);
void Tick();
BaseRoom* GetGameRoom(GameRoomId roomId) noexcept;
const BaseRoom* GetConstGameRoom(GameRoomId roomId) const noexcept;
private:
GameRoomId mNewRoomId;
std::map<ClientId, GameRoomId> mRoomOfPlayers;
std::map<GameRoomId, std::unique_ptr<BaseRoom>> mGameRooms;
std::queue<GameRoomId> mRoomDestroyQueue;
std::queue<ClientId> mMatchMakingQueue;
std::set<ClientId> mMatchMakingSet;
bool IsPlayerInGameRoom(ClientId clientId) const noexcept;
};
#endif //BATTLEGAME_SERVER_GAMEROOMMANAGER_H