> For the complete documentation index, see [llms.txt](https://reflective-roommanager.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reflective-roommanager.gitbook.io/docs/user-manual/network/room/managers/room-manager.md).

# Room Manager

This class derives from the `RoomManagerBase` class and provides basic room management functionality.

### Methods

1. ```csharp
   public override void CreateRoom(NetworkConnection conn = null,
   RoomInfo roomInfo = default)
   ```
   * This method creates a room.
   * **Function:**
     * Retrieves `roomName` and `maxPlayers` variables.
     * If there is another room with the same `roomName` in the `m_rooms` list, it gives a warning and terminates the process.
     * If the connection information (`conn`) is present, it indicates that the room belongs to a client. If not, it indicates that the room belongs to a server.
     * Creates a room object and fills the information for this room with the specified values.
     * Adds this room to the `m_rooms` list with the `RoomListUtility.AddRoomToList` method.
     * If the room belongs to a client, it sends the `ClientRoomState.Created` message to the client and loads the room. Once the installation is complete, it invites the client to join the room.
     * If the room belongs to a server, it loads the room.
     * triggers the corresponding event when the room is created (`OnServerCreatedRoom`).
2. ```csharp
   public override void JoinRoom(NetworkConnection conn, string roomName)
   ```
   * This method is called to join a specific room.
   * **Function:**
     * Searches for a room matching `roomName`.
     * If the room is not found, it raises a warning and sends the `ClientRoomState.Fail` message to the client.
     * If the room has the current game, it sends the `ClientRoomState.Fail` message to the client.
     * If the room is found, it adds the link to the room.
     * Updates room information and sends this information to all clients.
     * Sends the `ClientRoomState.Joined` message to the client.
     * Triggers the relevant event (`OnServerJoinedClient`).
3. ```csharp
   public override void RemoveAllRoom(bool forced = false)
   ```
   * This method removes all rooms.
   * **Function:**
     * Loops each room in the `m_rooms` list.
     * Removes each room with the `RemoveRoom` method.
4. ```csharp
   public override void RemoveRoom(string roomName, bool forced = false)
   ```
   * This method removes a specific room.
   * **Function:**
     * Searches for a room matching `roomName`.
     * If the room is not found, it gives a warning.
     * If the room belongs to a server and there is no forced removal, it terminates the process.
     * If the room belongs to a server, it removes all connections to the room.
     * Sends the `ClientRoomState.Removed` message to all connections in the room.
     * Removes it from the room's list.
5. ```csharp
   public override void ExitRoom(NetworkConnection conn, bool isDisconnected)
   ```
   * This method manages when a client leaves the room.
   * **Function:**
     * Finds the room the client left.
     * If the room is not found, it gives a warning.
     * If there is more than one player in the room and the client leaves the room, it updates the room's list.
     * Sends the `ClientRoomState.Exited` message to the client.
     * Triggers the relevant event (`OnServerExitedClient` or `OnServerDisconnectedClient`).
