Photon Unity Networking 2  v2.1
English | 日本語 | 한국
Public Member Functions | List of all members
IMatchmakingCallbacks Interface Reference

Collection of "organizational" callbacks for the Realtime Api to cover Matchmaking. More...

Inherited by MonoBehaviourPunCallbacks, PhotonHandler, OnJoinedInstantiate, MatchMakingCallbacksContainer, and SupportLogger.

Public Member Functions

void OnFriendListUpdate (List< FriendInfo > friendList)
 Called when the server sent the response to a FindFriends request. More...
 
void OnCreatedRoom ()
 Called when this client created a room and entered it. OnJoinedRoom() will be called as well. More...
 
void OnCreateRoomFailed (short returnCode, string message)
 Called when the server couldn't create a room (OpCreateRoom failed). More...
 
void OnJoinedRoom ()
 Called when the LoadBalancingClient entered a room, no matter if this client created it or simply joined. More...
 
void OnJoinRoomFailed (short returnCode, string message)
 Called when a previous OpJoinRoom call failed on the server. More...
 
void OnJoinRandomFailed (short returnCode, string message)
 Called when a previous OpJoinRandom 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...
 

Detailed Description

Collection of "organizational" callbacks for the Realtime Api to cover Matchmaking.

Classes that implement this interface must be registered to get callbacks for various situations.

To register for callbacks, PhotonNetwork.AddCallbackTarget(<Your Component implementing this interface>); To stop getting callbacks, PhotonNetwork.RemoveCallbackTarget(<Your Component implementing this interface>);

You can also simply override MonoBehaviourPunCallbacks which will provide you with Magic Callbacks ( like Unity would call Start(), Update() on a MonoBehaviour)

Member Function Documentation

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, and OnJoinedInstantiate.

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, and OnJoinedInstantiate.

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, and OnJoinedInstantiate.

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).

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, PlayerNumbering, ConnectAndJoinRandom, PunTeams, and OnJoinedInstantiate.

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, OnJoinedInstantiate, and ConnectAndJoinRandom.

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, and OnJoinedInstantiate.

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.

Implemented in MatchMakingCallbacksContainer, MonoBehaviourPunCallbacks, SupportLogger, OnJoinedInstantiate, PlayerNumbering, and PunTeams.