C# Class NetworkingPeer, Droid-Soccer

Inheritance: LoadbalancingPeer, IPhotonPeerListener
Afficher le fichier Open project: repelex/Droid-Soccer Class Usage Examples

Méthodes publiques

Свойство Type Description
IsInitialConnect bool
PrefabCache GameObject>.Dictionary
UsePrefabCache bool
hasSwitchedMC bool
insideLobby bool
mActors PhotonPlayer>.Dictionary
mGameList RoomInfo>.Dictionary
mGameListCopy RoomInfo[],
mOtherPlayerListCopy PhotonPlayer[],
mPlayerListCopy PhotonPlayer[],

Protected Properties

Свойство Type Description
LobbyStatistics List
currentLevelPrefix short
loadingLevelAndPausedNetwork bool
mAppId string
photonViewList PhotonView>.Dictionary

Private Properties

Свойство Type Description
AddNewPlayer void
AlmostEquals bool
CheckMasterClient void
CheckTypeMatch bool
DeltaCompressionRead bool
DeltaCompressionWrite bool
DisconnectToReconnect void
DoInstantiate GameObject
GameEnteredOnGameServer void
GetActorPropertiesForActorNr ExitGames.Client.Photon.Hashtable
GetLocalActorProperties ExitGames.Client.Photon.Hashtable
GetNameServerAddress string
HandleEventLeave void
LeftLobbyCleanup void
LeftRoomCleanup void
ObjectIsSameWithInprecision bool
OnSerializeRead void
OnSerializeWrite ExitGames.Client.Photon.Hashtable
OpRemoveFromServerInstantiationsOfPlayer void
RPC void
RPC void
ReadoutProperties void
RebuildPlayerListCopies void
RemoveCacheOfLeftPlayers void
RemoveInstantiationData void
RemovePlayer void
ResetPhotonViewsOnSerialize void
ReturnLowestPlayerId int
SendDestroyOfAll void
SendDestroyOfPlayer void
SendInstantiate ExitGames.Client.Photon.Hashtable
SendPlayerName void
SendVacantViewIds void
ServerCleanInstantiateAndDestroy void
StoreInstantiationData void

Méthodes publiques

Méthode Description
ChangeLocalID ( int newID ) : void
CleanRpcBufferIfMine ( PhotonView, view ) : void
Connect ( string serverAddress, ServerConnection, type ) : bool
Connect ( string serverAddress, string applicationName ) : bool
ConnectToNameServer ( ) : bool

Connects to the NameServer for Photon Cloud, where a region and server list can be obtained.

ConnectToRegionMaster ( CloudRegionCode region ) : bool

Connects you to a specific region's Master Server, using the Name Server to find the IP.

DebugReturn ( DebugLevel, level, string message ) : void
DestroyAll ( bool localOnly ) : void
DestroyPlayerObjects ( int playerId, bool localOnly ) : void

Destroys all Instantiates and RPCs locally and (if not localOnly) sends EvDestroy(player) and clears related events in the server buffer.

Disconnect ( ) : void

Complete disconnect from photon (and the open master OR game server)

FetchInstantiationData ( int instantiationId ) : object[]
GetInstantiatedObjectsId ( GameObject go ) : int

This returns -1 if the GO could not be found in list of instantiatedObjects.

GetPhotonView ( int viewID ) : PhotonView,
GetRegions ( ) : bool

While on the NameServer, this gets you the list of regional servers (short names and their IPs to ping them).

LocalCleanPhotonView ( PhotonView, view ) : bool
NetworkingPeer ( string playername, ConnectionProtocol connectionProtocol ) : System.Linq
NewSceneLoaded ( ) : void
OnEvent ( EventData, photonEvent ) : void
OnOperationResponse ( OperationResponse operationResponse ) : void
OnStatusChanged ( StatusCode statusCode ) : void
OpCleanRpcBuffer ( PhotonView, view ) : void

Cleans server RPCs for PhotonView (without any further checks).

OpCleanRpcBuffer ( int actorNumber ) : void

Removes the RPCs of someone else (to be used as master). This won't clean any local caches. It just tells the server to forget a player's RPCs and instantiates.

OpCreateGame ( EnterRoomParams, enterRoomParams ) : bool

NetworkingPeer.OpCreateGame

OpFindFriends ( string friendsToFind ) : bool

Request the rooms and online status for a list of friends. All client must set a unique username via PlayerName property. The result is available in this.Friends.

Used on Master Server to find the rooms played by a selected list of users. The result will be mapped to LoadBalancingClient.Friends when available. The list is initialized by OpFindFriends on first use (before that, it is null). Users identify themselves by setting a PlayerName in the LoadBalancingClient instance. This in turn will send the name in OpAuthenticate after each connect (to master and game servers). Note: Changing a player's name doesn't make sense when using a friend list. The list of usernames must be fetched from some other source (not provided by Photon). Internal: The server response includes 2 arrays of info (each index matching a friend from the request): ParameterCode.FindFriendsResponseOnlineList = bool[] of online states ParameterCode.FindFriendsResponseRoomIdList = string[] of room names (empty string if not in a room)

OpJoinRandomRoom ( OpJoinRandomRoomParams, opJoinRandomRoomParams ) : bool

NetworkingPeer.OpJoinRandomRoom

this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)

OpJoinRoom ( EnterRoomParams, opParams ) : bool

NetworkingPeer.OpJoinRoom

OpLeave ( ) : bool

Operation Leave will exit any current room.

This also happens when you disconnect from the server. Disconnect might be a step less if you don't want to create a new room on the same server.

OpRaiseEvent ( byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions, raiseEventOptions ) : bool
OpRemoveCompleteCache ( ) : void
OpRemoveCompleteCacheOfPlayer ( int actorNumber ) : void

Instead removing RPCs or Instantiates, this removed everything cached by the actor.

RegisterPhotonView ( PhotonView, netView ) : void
RemoveRPCsInGroup ( int group ) : void
RunViewUpdate ( ) : void
SendMonoMessage ( PhotonNetworkingMessage methodString ) : void
SetApp ( string appId, string gameVersion ) : void
SetLevelPrefix ( short prefix ) : void
SetMasterClient ( int nextMasterId ) : bool

Uses a well-known property to set someone new as Master Client in room (requires "Server Side Master Client" feature).

SetReceivingEnabled ( int group, bool enabled ) : void
SetReceivingEnabled ( int enableGroups, int disableGroups ) : void
SetSendingEnabled ( int group, bool enabled ) : void
SetSendingEnabled ( int enableGroups, int disableGroups ) : void
WebRpc ( string uriPath, object parameters ) : bool

Méthodes protégées

Méthode Description
ExecuteRpc ( ExitGames.Client.Photon.Hashtable rpcData, PhotonPlayer, sender ) : void

Executes a received RPC event

GetMethod ( MonoBehaviour monob, string methodType, MethodInfo &mi ) : bool
GetPlayerWithId ( int number ) : PhotonPlayer,
LoadLevelIfSynced ( ) : void

Internally used to detect the current scene and load it if PhotonNetwork.automaticallySyncScene is enabled.

LocalCleanupAnythingInstantiated ( bool destroyInstantiatedGameObjects ) : void

Cleans up anything that was instantiated in-game (not loaded with the scene).

RemoveInstantiatedGO ( GameObject go, bool localOnly ) : void

Removes GameObject and the PhotonViews on it from local lists and optionally updates remotes. GameObject gets destroyed at end.

This method might fail and quit early due to several tests.

RequestOwnership ( int viewID, int fromOwner ) : void
SetLevelInPropsIfSynced ( object levelId ) : void
SetMasterClient ( int playerId, bool sync ) : bool

Fake-sets a new Master Client for this room via RaiseEvent.

Does not affect RaiseEvent with target MasterClient but RPC().

TransferOwnership ( int viewID, int playerID ) : void
UpdateMasterClient ( ) : void

Call when the server provides a MasterClientId (due to joining or the current MC leaving, etc).

UpdatedActorList ( int actorsInRoom ) : void

Private Methods

Méthode Description
AddNewPlayer ( int ID, PhotonPlayer, player ) : void
AlmostEquals ( object lastData, object currentContent ) : bool
CheckMasterClient ( int leavingPlayerId ) : void

Picks the new master client from player list, if the current Master is leaving (leavingPlayerId) or if no master was assigned so far.

CheckTypeMatch ( ParameterInfo methodParameters, Type callParameterTypes ) : bool

Check if all types match with parameters. We can have more paramters then types (allow last RPC type to be different).

DeltaCompressionRead ( PhotonView, view, ExitGames.Client.Photon.Hashtable data ) : bool

reads incoming messages created by "OnSerialize"

DeltaCompressionWrite ( PhotonView, view, ExitGames.Client.Photon.Hashtable data ) : bool

Compares the new data with previously sent data and skips values that didn't change.

DisconnectToReconnect ( ) : void

Internally used only. Triggers OnStateChange with "Disconnect" in next dispatch which is the signal to re-connect (if at all).

DoInstantiate ( ExitGames.Client.Photon.Hashtable evData, PhotonPlayer, photonPlayer, GameObject resourceGameObject ) : GameObject
GameEnteredOnGameServer ( OperationResponse operationResponse ) : void
GetActorPropertiesForActorNr ( ExitGames.Client.Photon.Hashtable actorProperties, int actorNr ) : ExitGames.Client.Photon.Hashtable
GetLocalActorProperties ( ) : ExitGames.Client.Photon.Hashtable
GetNameServerAddress ( ) : string

Gets the NameServer Address (with prefix and port), based on the set protocol (this.UsedProtocol).

HandleEventLeave ( int actorID, EventData, evLeave ) : void

Called when the event Leave (of some other player) arrived. Cleans game objects, views locally. The master will also clean the

LeftLobbyCleanup ( ) : void

Called at disconnect/leavelobby etc. This CAN also be called when we are not in a lobby (e.g. disconnect from room)

Calls callback method OnLeftLobby if this client was in a lobby initially. Clears the lobby's game lists.

LeftRoomCleanup ( ) : void

Called when "this client" left a room to clean up.

ObjectIsSameWithInprecision ( object one, object two ) : bool

Returns true if both objects are almost identical. Used to check whether two objects are similar enough to skip an update.

OnSerializeRead ( ExitGames.Client.Photon.Hashtable data, PhotonPlayer, sender, int networkTime, short correctPrefix ) : void

Reads updates created by OnSerializeWrite

OnSerializeWrite ( PhotonView, view ) : ExitGames.Client.Photon.Hashtable
OpRemoveFromServerInstantiationsOfPlayer ( int actorNr ) : void
RPC ( PhotonView, view, string methodName, PhotonPlayer, player, bool encrypt ) : void
RPC ( PhotonView, view, string methodName, PhotonTargets target, bool encrypt ) : void
ReadoutProperties ( ExitGames.Client.Photon.Hashtable gameProperties, ExitGames.Client.Photon.Hashtable pActorProperties, int targetActorNr ) : void
RebuildPlayerListCopies ( ) : void
RemoveCacheOfLeftPlayers ( ) : void
RemoveInstantiationData ( int instantiationId ) : void
RemovePlayer ( int ID, PhotonPlayer, player ) : void
ResetPhotonViewsOnSerialize ( ) : void

Resets the PhotonView "lastOnSerializeDataSent" so that "OnReliable" synched PhotonViews send a complete state to new clients (if the state doesnt change, no messages would be send otherwise!). Note that due to this reset, ALL other players will receive the full OnSerialize.

ReturnLowestPlayerId ( PhotonPlayer, players, int playerIdToIgnore ) : int
SendDestroyOfAll ( ) : void
SendDestroyOfPlayer ( int actorNr ) : void
SendInstantiate ( string prefabName, Vector3 position, Quaternion rotation, int group, int viewIDs, object data, bool isGlobalObject ) : ExitGames.Client.Photon.Hashtable
SendPlayerName ( ) : void
SendVacantViewIds ( ) : void
ServerCleanInstantiateAndDestroy ( int instantiateId, int creatorId, bool isRuntimeInstantiated ) : void

Removes an instantiation event from the server's cache. Needs id and actorNr of player who instantiated.

StoreInstantiationData ( int instantiationId, object instantiationData ) : void

Method Details

ChangeLocalID() public méthode

public ChangeLocalID ( int newID ) : void
newID int
Résultat void

CleanRpcBufferIfMine() public méthode

public CleanRpcBufferIfMine ( PhotonView, view ) : void
view PhotonView,
Résultat void

Connect() public méthode

public Connect ( string serverAddress, ServerConnection, type ) : bool
serverAddress string
type ServerConnection,
Résultat bool

Connect() public méthode

public Connect ( string serverAddress, string applicationName ) : bool
serverAddress string
applicationName string
Résultat bool

ConnectToNameServer() public méthode

Connects to the NameServer for Photon Cloud, where a region and server list can be obtained.
public ConnectToNameServer ( ) : bool
Résultat bool

ConnectToRegionMaster() public méthode

Connects you to a specific region's Master Server, using the Name Server to find the IP.
public ConnectToRegionMaster ( CloudRegionCode region ) : bool
region CloudRegionCode
Résultat bool

DebugReturn() public méthode

public DebugReturn ( DebugLevel, level, string message ) : void
level DebugLevel,
message string
Résultat void

DestroyAll() public méthode

public DestroyAll ( bool localOnly ) : void
localOnly bool
Résultat void

DestroyPlayerObjects() public méthode

Destroys all Instantiates and RPCs locally and (if not localOnly) sends EvDestroy(player) and clears related events in the server buffer.
public DestroyPlayerObjects ( int playerId, bool localOnly ) : void
playerId int
localOnly bool
Résultat void

Disconnect() public méthode

Complete disconnect from photon (and the open master OR game server)
public Disconnect ( ) : void
Résultat void

ExecuteRpc() protected méthode

Executes a received RPC event
protected ExecuteRpc ( ExitGames.Client.Photon.Hashtable rpcData, PhotonPlayer, sender ) : void
rpcData ExitGames.Client.Photon.Hashtable
sender PhotonPlayer,
Résultat void

FetchInstantiationData() public méthode

public FetchInstantiationData ( int instantiationId ) : object[]
instantiationId int
Résultat object[]

GetInstantiatedObjectsId() public méthode

This returns -1 if the GO could not be found in list of instantiatedObjects.
public GetInstantiatedObjectsId ( GameObject go ) : int
go GameObject
Résultat int

GetMethod() protected static méthode

protected static GetMethod ( MonoBehaviour monob, string methodType, MethodInfo &mi ) : bool
monob MonoBehaviour
methodType string
mi MethodInfo
Résultat bool

GetPhotonView() public méthode

public GetPhotonView ( int viewID ) : PhotonView,
viewID int
Résultat PhotonView,

GetPlayerWithId() protected méthode

protected GetPlayerWithId ( int number ) : PhotonPlayer,
number int
Résultat PhotonPlayer,

GetRegions() public méthode

While on the NameServer, this gets you the list of regional servers (short names and their IPs to ping them).
public GetRegions ( ) : bool
Résultat bool

LoadLevelIfSynced() protected méthode

Internally used to detect the current scene and load it if PhotonNetwork.automaticallySyncScene is enabled.
protected LoadLevelIfSynced ( ) : void
Résultat void

LocalCleanPhotonView() public méthode

public LocalCleanPhotonView ( PhotonView, view ) : bool
view PhotonView,
Résultat bool

LocalCleanupAnythingInstantiated() protected méthode

Cleans up anything that was instantiated in-game (not loaded with the scene).
protected LocalCleanupAnythingInstantiated ( bool destroyInstantiatedGameObjects ) : void
destroyInstantiatedGameObjects bool
Résultat void

NetworkingPeer() public méthode

public NetworkingPeer ( string playername, ConnectionProtocol connectionProtocol ) : System.Linq
playername string
connectionProtocol ConnectionProtocol
Résultat System.Linq

NewSceneLoaded() public méthode

public NewSceneLoaded ( ) : void
Résultat void

OnEvent() public méthode

public OnEvent ( EventData, photonEvent ) : void
photonEvent EventData,
Résultat void

OnOperationResponse() public méthode

public OnOperationResponse ( OperationResponse operationResponse ) : void
operationResponse OperationResponse
Résultat void

OnStatusChanged() public méthode

public OnStatusChanged ( StatusCode statusCode ) : void
statusCode StatusCode
Résultat void

OpCleanRpcBuffer() public méthode

Cleans server RPCs for PhotonView (without any further checks).
public OpCleanRpcBuffer ( PhotonView, view ) : void
view PhotonView,
Résultat void

OpCleanRpcBuffer() public méthode

Removes the RPCs of someone else (to be used as master). This won't clean any local caches. It just tells the server to forget a player's RPCs and instantiates.
public OpCleanRpcBuffer ( int actorNumber ) : void
actorNumber int
Résultat void

OpCreateGame() public méthode

NetworkingPeer.OpCreateGame
public OpCreateGame ( EnterRoomParams, enterRoomParams ) : bool
enterRoomParams EnterRoomParams,
Résultat bool

OpFindFriends() public méthode

Request the rooms and online status for a list of friends. All client must set a unique username via PlayerName property. The result is available in this.Friends.
Used on Master Server to find the rooms played by a selected list of users. The result will be mapped to LoadBalancingClient.Friends when available. The list is initialized by OpFindFriends on first use (before that, it is null). Users identify themselves by setting a PlayerName in the LoadBalancingClient instance. This in turn will send the name in OpAuthenticate after each connect (to master and game servers). Note: Changing a player's name doesn't make sense when using a friend list. The list of usernames must be fetched from some other source (not provided by Photon). Internal: The server response includes 2 arrays of info (each index matching a friend from the request): ParameterCode.FindFriendsResponseOnlineList = bool[] of online states ParameterCode.FindFriendsResponseRoomIdList = string[] of room names (empty string if not in a room)
public OpFindFriends ( string friendsToFind ) : bool
friendsToFind string Array of friend's names (make sure they are unique).
Résultat bool

OpJoinRandomRoom() public méthode

NetworkingPeer.OpJoinRandomRoom
this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)
public OpJoinRandomRoom ( OpJoinRandomRoomParams, opJoinRandomRoomParams ) : bool
opJoinRandomRoomParams OpJoinRandomRoomParams,
Résultat bool

OpJoinRoom() public méthode

NetworkingPeer.OpJoinRoom
public OpJoinRoom ( EnterRoomParams, opParams ) : bool
opParams EnterRoomParams,
Résultat bool

OpLeave() public méthode

Operation Leave will exit any current room.
This also happens when you disconnect from the server. Disconnect might be a step less if you don't want to create a new room on the same server.
public OpLeave ( ) : bool
Résultat bool

OpRaiseEvent() public méthode

public OpRaiseEvent ( byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions, raiseEventOptions ) : bool
eventCode byte
customEventContent object
sendReliable bool
raiseEventOptions RaiseEventOptions,
Résultat bool

OpRemoveCompleteCache() public méthode

public OpRemoveCompleteCache ( ) : void
Résultat void

OpRemoveCompleteCacheOfPlayer() public méthode

Instead removing RPCs or Instantiates, this removed everything cached by the actor.
public OpRemoveCompleteCacheOfPlayer ( int actorNumber ) : void
actorNumber int
Résultat void

RegisterPhotonView() public méthode

public RegisterPhotonView ( PhotonView, netView ) : void
netView PhotonView,
Résultat void

RemoveInstantiatedGO() protected méthode

Removes GameObject and the PhotonViews on it from local lists and optionally updates remotes. GameObject gets destroyed at end.
This method might fail and quit early due to several tests.
protected RemoveInstantiatedGO ( GameObject go, bool localOnly ) : void
go GameObject GameObject to cleanup.
localOnly bool For localOnly, tests of control are skipped and the server is not updated.
Résultat void

RemoveRPCsInGroup() public méthode

public RemoveRPCsInGroup ( int group ) : void
group int
Résultat void

RequestOwnership() protected méthode

protected RequestOwnership ( int viewID, int fromOwner ) : void
viewID int
fromOwner int
Résultat void

RunViewUpdate() public méthode

public RunViewUpdate ( ) : void
Résultat void

SendMonoMessage() public static méthode

public static SendMonoMessage ( PhotonNetworkingMessage methodString ) : void
methodString PhotonNetworkingMessage
Résultat void

SetApp() public méthode

public SetApp ( string appId, string gameVersion ) : void
appId string
gameVersion string
Résultat void

SetLevelInPropsIfSynced() protected méthode

protected SetLevelInPropsIfSynced ( object levelId ) : void
levelId object
Résultat void

SetLevelPrefix() public méthode

public SetLevelPrefix ( short prefix ) : void
prefix short
Résultat void

SetMasterClient() public méthode

Uses a well-known property to set someone new as Master Client in room (requires "Server Side Master Client" feature).
public SetMasterClient ( int nextMasterId ) : bool
nextMasterId int
Résultat bool

SetMasterClient() protected méthode

Fake-sets a new Master Client for this room via RaiseEvent.
Does not affect RaiseEvent with target MasterClient but RPC().
protected SetMasterClient ( int playerId, bool sync ) : bool
playerId int
sync bool
Résultat bool

SetReceivingEnabled() public méthode

public SetReceivingEnabled ( int group, bool enabled ) : void
group int
enabled bool
Résultat void

SetReceivingEnabled() public méthode

public SetReceivingEnabled ( int enableGroups, int disableGroups ) : void
enableGroups int
disableGroups int
Résultat void

SetSendingEnabled() public méthode

public SetSendingEnabled ( int group, bool enabled ) : void
group int
enabled bool
Résultat void

SetSendingEnabled() public méthode

public SetSendingEnabled ( int enableGroups, int disableGroups ) : void
enableGroups int
disableGroups int
Résultat void

TransferOwnership() protected méthode

protected TransferOwnership ( int viewID, int playerID ) : void
viewID int
playerID int
Résultat void

UpdateMasterClient() protected méthode

Call when the server provides a MasterClientId (due to joining or the current MC leaving, etc).
protected UpdateMasterClient ( ) : void
Résultat void

UpdatedActorList() protected méthode

protected UpdatedActorList ( int actorsInRoom ) : void
actorsInRoom int
Résultat void

WebRpc() public méthode

public WebRpc ( string uriPath, object parameters ) : bool
uriPath string
parameters object
Résultat bool

Property Details

IsInitialConnect public_oe property

public bool IsInitialConnect
Résultat bool

LobbyStatistics protected_oe property

protected List LobbyStatistics
Résultat List

PrefabCache public_oe static_oe property

public static Dictionary PrefabCache
Résultat GameObject>.Dictionary

UsePrefabCache public_oe static_oe property

public static bool UsePrefabCache
Résultat bool

currentLevelPrefix protected_oe property

protected short currentLevelPrefix
Résultat short

hasSwitchedMC public_oe property

public bool hasSwitchedMC
Résultat bool

insideLobby public_oe property

public bool insideLobby
Résultat bool

loadingLevelAndPausedNetwork protected_oe property

Internally used to flag if the message queue was disabled by a "scene sync" situation (to re-enable it).
protected bool loadingLevelAndPausedNetwork
Résultat bool

mActors public_oe property

public Dictionary mActors
Résultat PhotonPlayer>.Dictionary

mAppId protected_oe property

Contains the AppId for the Photon Cloud (ignored by Photon Servers).
protected string mAppId
Résultat string

mGameList public_oe property

public Dictionary mGameList
Résultat RoomInfo>.Dictionary

mGameListCopy public_oe property

public RoomInfo[], mGameListCopy
Résultat RoomInfo[],

mOtherPlayerListCopy public_oe property

public PhotonPlayer[], mOtherPlayerListCopy
Résultat PhotonPlayer[],

mPlayerListCopy public_oe property

public PhotonPlayer[], mPlayerListCopy
Résultat PhotonPlayer[],

photonViewList protected_oe property

protected Dictionary photonViewList
Résultat PhotonView>.Dictionary