Room Manager
This class derives from the RoomManagerBase
class and provides basic room management functionality.
Methods
This method creates a room.
Function:
Retrieves
roomName
andmaxPlayers
variables.If there is another room with the same
roomName
in them_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 theRoomListUtility.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
).
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
).
This method removes all rooms.
Function:
Loops each room in the
m_rooms
list.Removes each room with the
RemoveRoom
method.
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.
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
orOnServerDisconnectedClient
).
Last updated