NetworkClient.Lobby invokes the following events to help you keep track of rooms states and receive messages from other players.
Some of the events (OnLobbyConnectedEvent, OnRoomReadyEvent) are important to keep the matchmaking process running.
If you have a lobby interface, you might be interested in events like OnNewPlayerJoinRoomEvent, OnPlayerLeaveRoomEvent, and OnRoomCustomDataChangeEvent.
Event
Invoked when the local player connected to the lobby server.
Invoked when a new player message is received.
Invoked when the room custom data is updated.
Invoked when new players join the local player's room.
Invoked when players leave the local player's room.
Invoked when the room owner is changed.
Invoked when the room changes to the Starting state.
Game servers are being prepared for the room.
If no available game servers are found, FailedToStartRoomEvent will be invoked.
If game servers are prepared, RoomReadyEvent will be invoked.
Invoked when the room changes to the Rooms Set state.
Game servers for the room are prepared.
Use NetworkClient.Instance.ConnectToRoom(Action) to connect to the game servers.
Invoked when the room fails to start.
No game servers are available.
Invoked when a new room message is received.
Invoked when the player is kicked from the room by the room owner.
Example
In this example, we added listeners to the lobby room events in the Start() method and removed the listeners in the OnDestroy() method.