Room Manager Base

This abstract class provides network-based room management functionality. This class also includes the management of scenes.

Serialize Members

  • bool _dontDestroyOnLoad:

    • Specifies whether the room manager will be destroyed during scene changes.

  • LocalPhysicsMode _physicsMode:

    • Represents the native physics mode (3D or 2D).

  • string _lobbyScene:

    • The name of the lobby scene where the players enter.

  • string _roomScene:

    • The name of the room scene.

  • RoomData_SO _defaultRoomData:

    • A ScriptableObject containing the default room data.

General Members

  • public static RoomManagerBase Singleton:

    • Represents a single instance of RoomManagerBase.

  • public LocalPhysicsMode PhysicsMode:

    • Returns the native physics mode.

  • public RoomData_SO RoomData:

    • Returns room data.

  • public string LobbyScene:

    • Returns the name of the lobby scene.

  • public string RoomScene:

    • Returns the name of the room scene.

Methods

  1. protected virtual void Awake()
    • This method is run at wakeup time of a class inherited from MonoBehaviour. In this case, the RoomManagerBase class will run as soon as it wakes up. This method does the basic configuration of the room manager.

    • Function:

      • The InitializeSingleton() method is called. This method ensures that there is a single instance of the room manager and ensures that it is destroyed during scene changes when necessary.

      • The InitializeRoomLoader() method is called. This method launches the loader, which will provide the functionality to load or unload rooms.

  2. private bool InitializeSingleton()
    • This method checks if there is a single instance of the room manager. It also allows it to be destroyed during scene changes when necessary.

    • Function:

      • If _singleton already exists and belongs to this class, it completes the operation.

      • If _dontDestroyOnLoad is not set, it assigns the _singleton to this object.

      • If _singleton already exists and does not belong to this class, then it destroys the second instance to avoid conflict.

  3. private void InitializeRoomLoader()
    • This method starts the room loader. This loader provides the functionality of loading or unloading chambers.

    • İşlevi:

      • The _roomLoader variable is determined by the room loading type specified in _defaultRoomData.

  4. protected virtual void OnStartServer()
    • This method runs when the server is started.

    • Function:

      • The ConnectionManager.roomConnections.AddRegistersForServer() method is called. This method saves connections on the server side.

  5. protected virtual void OnStopServer()
    • This method runs when the server is stopped.

    • Function:

      • The RemoveAllRoom(forced:true) method is called. This removes all rooms and links.

  6. protected virtual void OnStartClient()
    • This method runs when the client is started.

    • İşlevi:

      • The ConnectionManager.roomConnections.AddRegistersForClient() method is called. This method saves connections on the client side.

  7. protected virtual void OnStopClient()
    • Bu metod, istemci durdurulduğunda çalışır.

    • Function:

      • Bu metodun şu anki implementasyonunda herhangi bir işlev yok.

  8. protected virtual void OnServerConnect(NetworkConnection conn)
    • This method runs when a client connects to the server.

    • Function:

      • SendUpdateRoomListForClient(conn) method is called. This sends the available room list to the newly connected client.

      • SendConnectionMessageToClient(conn) method is called. This sends the connection ID to the connecting client.

  9. protected virtual void OnServerDisconnect(NetworkConnectionToClient conn)
    • This method runs when a client leaves the server.

    • Function:

      • The ExitRoom(conn, true) method is called. This removes the connecting client from the room and connections.

  10. protected virtual void OnClientConnect()
    • This method runs when a client connects to the server.

  11. protected virtual void OnClientDisconnect()
    • Bu metod, bir istemci sunucudan ayrıldığında çalışır.

  12. public IEnumerable<Room> GetRooms()
    • This method returns a list of all rooms.

    • Function:

      • This method returns all available rooms by returning the list _rooms.

  13. public IEnumerable<RoomInfo> GetRoomInfos()
    • This method returns a list of all room information.

    • Function:

      • This method returns all available room information by returning the list _roomListInfos.

  14. public Room GetRoomOfPlayer(NetworkConnection conn)
    • This method returns the room to which the specified network connection is connected.

    • Function:

      • Checks each room in the _rooms list.

      • If a link with this link is found within a room, it will rotate the room.

  15. public RoomInfo GetRoomOfClient()
    • This method returns the room information to which the client is connected.

    • Function:

      • Checks each room information in the _roomListInfos list.

      • If this client's connection ID is included in a room information, it returns that room information.

  16. public Room GetRoomOfScene(Scene scene)
    • This method returns the room in the specified scene.

    • Function:

      • Checks each room in the _rooms list.

      • If the room matches the specified scene, it returns the room.

  17. public static void RequestCreateRoom(RoomInfo roomInfo)
    • This method sends a request to the server to create a new room.

    • Function:

      • If there is no network client, it terminates the process.

      • ServerRoomMessage is created and sent with this client's request.

  18. public static void RequestJoinRoom(string roomName)
    • This method sends a request to join the specified rooms.

    • Function:

      • If there is no network client, it terminates the process.

      • ServerRoomMessage is created and sent with this client's request.

  19. public static void RequestExitRoom(bool isDisconnected = false)
    • This method sends a request to leave the room the client is in.

    • Function:

      • EIf there is no network client, it terminates the process.

      • ServerRoomMessage is created and sent with this client's request.

  20. protected void LoadRoom(Room room, RoomInfo roomInfo, Action onLoaded = null)
    • This method loads the specified room.

    • Function:

      • If _roomLoader is still not assigned it will throw an error.

      • Loads the room by calling the LoadRoom method of _roomLoader.

  21. protected void UnLoadRoom(Room room)
    • This method vacates the specified room.

    • Function:

      • If _roomLoader is still not assigned it will throw an error.

      • Frees the room by calling _roomLoader's UnLoadRoom method.

  22. public abstract void CreateRoom(NetworkConnection conn = null,
    RoomInfo roomInfo = default);
    • This abstract method creates a room.

    • Function:

      • How to implement this method is left to the subclasses. Therefore, derived classes must implement this method.

  23. public abstract void JoinRoom(NetworkConnection conn, string roomName);
    • This abstract method performs the operations required to join a room.

    • Function:

      • How to implement this method is left to the subclasses. Therefore, derived classes must implement this method.

  24. public abstract void RemoveAllRoom(bool forced = false);
    • This abstract method removes all rooms and links.

    • Function:

      • How to implement this method is left to the subclasses. Therefore, derived classes must implement this method.

  25. public abstract void RemoveRoom(string roomName, bool forced = false);
    • This abstract method removes a specified room and clears the connections.

    • Function:

      • How to implement this method is left to the subclasses. Therefore, derived classes must implement this method.

  26. public abstract void ExitRoom(NetworkConnection conn, bool isDisconnected);
    • This abstract method handles a client leaving the room.

    • Function:

      • How to implement this method is left to the subclasses. Therefore, derived classes must implement this method.

  27. private static void GetConnectionMessageForClient(int connectionID)
    • This method retrieves the client's connection ID and assigns this information to the RoomClient.ID variable.

  28. private static void SendConnectionMessageToClient(NetworkConnection conn)
    • This method sends the connection ID message to the specified network connection.

  29. private void SendUpdateRoomListForClient(NetworkConnection conn)
    • This method sends a list of available rooms to a client.

  30. private void SendClientJoinSceneMessage(NetworkConnection conn)
    • This method sends a message to a client to load the scene when they join the room.

  31. private void SendClientExitSceneMessage(NetworkConnection conn)
    • This method sends a message to a client to vacate the stage when they leave the room.

  32. private void AddRoomList(RoomInfo roomInfo)
    • This method adds a room information to the rooms list.

  33. private void UpdateRoomList(RoomInfo roomInfo)
    • This method updates a room information.

  34. private void RemoveRoomList(RoomInfo roomInfo)
    • This method removes a room information from the rooms list.

Last updated