Photon Unity Networking 2 2.30

Public Member Functions | List of all members
MatchMakingCallbacksContainer Class Reference

Container type for callbacks defined by IMatchmakingCallbacks. See MatchMakingCallbackTargets. More...

Inherits List< IMatchmakingCallbacks >, and IMatchmakingCallbacks.

Public Member Functions

 MatchMakingCallbacksContainer (LoadBalancingClient client)
 
void OnCreatedRoom ()
 Called when this client created a room and entered it. OnJoinedRoom() will be called as well. More...
 
void OnJoinedRoom ()
 Called when the LoadBalancingClient entered a room, no matter if this client created it or simply joined. More...
 
void OnCreateRoomFailed (short returnCode, string message)
 Called when the server couldn't create a room (OpCreateRoom failed). More...
 
void OnJoinRandomFailed (short returnCode, string message)
 Called when a previous OpJoinRandom call failed on the server. More...
 
void OnJoinRoomFailed (short returnCode, string message)
 Called when a previous OpJoinRoom call failed on the server. More...
 
void OnLeftRoom ()
 Called when the local user/client left a room, so the game's logic can clean up it's internal state. More...
 
void OnFriendListUpdate (List< FriendInfo > friendList)
 Called when the server sent the response to a FindFriends request. More...
 

Detailed Description

Container type for callbacks defined by IMatchmakingCallbacks. See MatchMakingCallbackTargets.

While the interfaces of callbacks wrap up the methods that will be called, the container classes implement a simple way to call a method on all registered objects.

Member Function Documentation

◆ OnCreatedRoom()

void OnCreatedRoom ( )

Called when this client created a room and entered it. OnJoinedRoom() will be called as well.

This callback is only called on the client which created a room (see OpCreateRoom).

As any client might close (or drop connection) anytime, there is a chance that the creator of a room does not execute OnCreatedRoom.

If you need specific room properties or a "start signal", implement OnMasterClientSwitched() and make each new MasterClient check the room's state.

Implements IMatchmakingCallbacks.

◆ OnCreateRoomFailed()

void OnCreateRoomFailed ( short  returnCode,
string  message 
)

Called when the server couldn't create a room (OpCreateRoom failed).

Creating a room may fail for various reasons. Most often, the room already exists (roomname in use) or the RoomOptions clash and it's impossible to create the room.

When creating a room fails on a Game Server: The client will cache the failure internally and returns to the Master Server before it calls the fail-callback. This way, the client is ready to find/create a room at the moment of the callback. In this case, the client skips calling OnConnectedToMaster but returning to the Master Server will still call OnConnected. Treat callbacks of OnConnected as pure information that the client could connect.

Parameters
returnCodeOperation ReturnCode from the server.
messageDebug message for the error.

Implements IMatchmakingCallbacks.

◆ OnFriendListUpdate()

void OnFriendListUpdate ( List< FriendInfo friendList)

Called when the server sent the response to a FindFriends request.

After calling OpFindFriends, the Master Server will cache the friend list and send updates to the friend list. The friends includes the name, userId, online state and the room (if any) for each requested user/friend.

Use the friendList to update your UI and store it, if the UI should highlight changes.

Implements IMatchmakingCallbacks.

◆ OnJoinedRoom()

void OnJoinedRoom ( )

Called when the LoadBalancingClient entered a room, no matter if this client created it or simply joined.

When this is called, you can access the existing players in Room.Players, their custom properties and Room.CustomProperties.

In this callback, you could create player objects. For example in Unity, instantiate a prefab for the player.

If you want a match to be started "actively", enable the user to signal "ready" (using OpRaiseEvent or a Custom Property).

Implements IMatchmakingCallbacks.

◆ OnJoinRandomFailed()

void OnJoinRandomFailed ( short  returnCode,
string  message 
)

Called when a previous OpJoinRandom call failed on the server.

The most common causes are that a room is full or does not exist (due to someone else being faster or closing the room).

This operation is only ever sent to the Master Server. Once a room is found by the Master Server, the client will head off to the designated Game Server and use the operation Join on the Game Server.

When using multiple lobbies (via OpJoinLobby or a TypedLobby parameter), another lobby might have more/fitting rooms.

Parameters
returnCodeOperation ReturnCode from the server.
messageDebug message for the error.

Implements IMatchmakingCallbacks.

◆ OnJoinRoomFailed()

void OnJoinRoomFailed ( short  returnCode,
string  message 
)

Called when a previous OpJoinRoom call failed on the server.

Joining a room may fail for various reasons. Most often, the room is full or does not exist anymore (due to someone else being faster or closing the room).

When joining a room fails on a Game Server: The client will cache the failure internally and returns to the Master Server before it calls the fail-callback. This way, the client is ready to find/create a room at the moment of the callback. In this case, the client skips calling OnConnectedToMaster but returning to the Master Server will still call OnConnected. Treat callbacks of OnConnected as pure information that the client could connect.

Parameters
returnCodeOperation ReturnCode from the server.
messageDebug message for the error.

Implements IMatchmakingCallbacks.

◆ OnLeftRoom()

void OnLeftRoom ( )

Called when the local user/client left a room, so the game's logic can clean up it's internal state.

When leaving a room, the LoadBalancingClient will disconnect the Game Server and connect to the Master Server. This wraps up multiple internal actions.

Wait for the callback OnConnectedToMaster, before you use lobbies and join or create rooms.

Implements IMatchmakingCallbacks.