network: Move global state into a seperate class

Co-Authored-By: Narr the Reg <5944268+german77@users.noreply.github.com>
This commit is contained in:
FearlessTobi 2022-07-22 16:31:13 +02:00
parent 899c8bb330
commit 7d82e57b91
21 changed files with 152 additions and 98 deletions

View file

@ -10,16 +10,25 @@
namespace Network {
/// Initializes and registers the network device, the room, and the room member.
bool Init();
class RoomNetwork {
public:
RoomNetwork();
/// Returns a pointer to the room handle
std::weak_ptr<Room> GetRoom();
/// Initializes and registers the network device, the room, and the room member.
bool Init();
/// Returns a pointer to the room member handle
std::weak_ptr<RoomMember> GetRoomMember();
/// Returns a pointer to the room handle
std::weak_ptr<Room> GetRoom();
/// Unregisters the network device, the room, and the room member and shut them down.
void Shutdown();
/// Returns a pointer to the room member handle
std::weak_ptr<RoomMember> GetRoomMember();
/// Unregisters the network device, the room, and the room member and shut them down.
void Shutdown();
private:
std::shared_ptr<RoomMember> g_room_member; ///< RoomMember (Client) for network games
std::shared_ptr<Room> g_room; ///< Room (Server) for network games
};
} // namespace Network