Photon Unity Networking 2: ConnectAndJoinRandom Class Reference

Photon Unity Networking 2

ConnectAndJoinRandom Class Reference

Simple component to call ConnectUsingSettings and to get into a PUN room easily. More...

Inherits MonoBehaviourPunCallbacks.

Public Member Functions

void Start ()
 
void ConnectNow ()
 
override void OnConnectedToMaster ()
 Called when the client is connected to the Master Server and ready for matchmaking and other tasks. More...
 
override void OnJoinedLobby ()
 Called on entering a lobby on the Master Server. The actual room-list updates will call OnRoomListUpdate. More...
 
override void OnJoinRandomFailed (short returnCode, string message)
 Called when a previous OpJoinRandom call failed on the server. More...
 
override void OnDisconnected (DisconnectCause cause)
 Called after disconnecting from the Photon server. It could be a failure or intentional More...
 
override void OnJoinedRoom ()
 Called when the LoadBalancingClient entered a room, no matter if this client created it or simply joined. More...
 
- Public Member Functions inherited from MonoBehaviourPunCallbacks
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void OnConnected ()
 Called to signal that the raw connection got established but before the client can call operation on the server. More...
 
virtual void OnLeftRoom ()
 Called when the local user/client left a room, so the game's logic can clean up it's internal state. More...
 
virtual void OnMasterClientSwitched (Player newMasterClient)
 Called after switching to a new MasterClient when the current one leaves. More...
 
virtual void OnCreateRoomFailed (short returnCode, string message)
 Called when the server couldn't create a room (OpCreateRoom failed). More...
 
virtual void OnJoinRoomFailed (short returnCode, string message)
 Called when a previous OpJoinRoom call failed on the server. More...
 
virtual void OnCreatedRoom ()
 Called when this client created a room and entered it. OnJoinedRoom() will be called as well. More...
 
virtual void OnLeftLobby ()
 Called after leaving a lobby. More...
 
virtual void OnRegionListReceived (RegionHandler regionHandler)
 Called when the Name Server provided a list of regions for your title. More...
 
virtual void OnRoomListUpdate (List< RoomInfo > roomList)
 Called for any update of the room-listing while in a lobby (InLobby) on the Master Server. More...
 
virtual void OnPlayerEnteredRoom (Player newPlayer)
 Called when a remote player entered the room. This Player is already added to the playerlist. More...
 
virtual void OnPlayerLeftRoom (Player otherPlayer)
 Called when a remote player left the room or became inactive. Check otherPlayer.IsInactive. More...
 
virtual void OnRoomPropertiesUpdate (Hashtable propertiesThatChanged)
 Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties. More...
 
virtual void OnPlayerPropertiesUpdate (Player target, Hashtable changedProps)
 Called when custom player-properties are changed. Player and the changed properties are passed as object[]. More...
 
virtual void OnFriendListUpdate (List< FriendInfo > friendList)
 Called when the server sent the response to a FindFriends request. More...
 
virtual void OnCustomAuthenticationResponse (Dictionary< string, object > data)
 Called when your Custom Authentication service responds with additional data. More...
 
virtual void OnCustomAuthenticationFailed (string debugMessage)
 Called when the custom authentication failed. Followed by disconnect! More...
 
virtual void OnWebRpcResponse (OperationResponse response)
 
virtual void OnLobbyStatisticsUpdate (List< TypedLobbyInfo > lobbyStatistics)
 Called when the Master Server sent an update for the Lobby Statistics, updating PhotonNetwork.LobbyStatistics. More...
 

Public Attributes

bool AutoConnect = true
 Connect automatically? If false you can set this to true later on or call ConnectUsingSettings in your own scripts. More...
 
byte Version = 1
 Used as PhotonNetwork.GameVersion. More...
 

Additional Inherited Members

- Properties inherited from MonoBehaviourPun
PhotonView photonView [get]
 A cached reference to a PhotonView on this GameObject. More...
 

Detailed Description

Simple component to call ConnectUsingSettings and to get into a PUN room easily.

A custom inspector provides a button to connect in PlayMode, should AutoConnect be false.

Member Function Documentation

override void OnConnectedToMaster ( )
virtual

Called when the client is connected to the Master Server and ready for matchmaking and other tasks.

The list of available rooms won't become available unless you join a lobby via LoadBalancingClient.OpJoinLobby. You can join rooms and create them even without being in a lobby. The default lobby is used in that case.

Reimplemented from MonoBehaviourPunCallbacks.

override void OnDisconnected ( DisconnectCause  cause)
virtual

Called after disconnecting from the Photon server. It could be a failure or intentional

The reason for this disconnect is provided as DisconnectCause.

Reimplemented from MonoBehaviourPunCallbacks.

override void OnJoinedLobby ( )
virtual

Called on entering a lobby on the Master Server. The actual room-list updates will call OnRoomListUpdate.

While in the lobby, the roomlist is automatically updated in fixed intervals (which you can't modify in the public cloud). The room list gets available via OnRoomListUpdate.

Reimplemented from MonoBehaviourPunCallbacks.

override void OnJoinedRoom ( )
virtual

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

Reimplemented from MonoBehaviourPunCallbacks.

override void OnJoinRandomFailed ( short  returnCode,
string  message 
)
virtual

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

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.

Reimplemented from MonoBehaviourPunCallbacks.

Member Data Documentation

bool AutoConnect = true

Connect automatically? If false you can set this to true later on or call ConnectUsingSettings in your own scripts.

byte Version = 1
Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH