C# Класс NetworkingPeer, Droid-Soccer

Наследование: LoadbalancingPeer, IPhotonPeerListener
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
IsInitialConnect bool
PrefabCache GameObject>.Dictionary
UsePrefabCache bool
hasSwitchedMC bool
insideLobby bool
mActors PhotonPlayer>.Dictionary
mGameList RoomInfo>.Dictionary
mGameListCopy RoomInfo[],
mOtherPlayerListCopy PhotonPlayer[],
mPlayerListCopy PhotonPlayer[],

Защищенные свойства (Protected)

Свойство Тип Описание
LobbyStatistics List
currentLevelPrefix short
loadingLevelAndPausedNetwork bool
mAppId string
photonViewList PhotonView>.Dictionary

Private Properties

Свойство Тип Описание
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

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

ChangeLocalID() публичный Метод

public ChangeLocalID ( int newID ) : void
newID int
Результат void

CleanRpcBufferIfMine() публичный Метод

public CleanRpcBufferIfMine ( PhotonView, view ) : void
view PhotonView,
Результат void

Connect() публичный Метод

public Connect ( string serverAddress, ServerConnection, type ) : bool
serverAddress string
type ServerConnection,
Результат bool

Connect() публичный Метод

public Connect ( string serverAddress, string applicationName ) : bool
serverAddress string
applicationName string
Результат bool

ConnectToNameServer() публичный Метод

Connects to the NameServer for Photon Cloud, where a region and server list can be obtained.
public ConnectToNameServer ( ) : bool
Результат bool

ConnectToRegionMaster() публичный Метод

Connects you to a specific region's Master Server, using the Name Server to find the IP.
public ConnectToRegionMaster ( CloudRegionCode region ) : bool
region CloudRegionCode
Результат bool

DebugReturn() публичный Метод

public DebugReturn ( DebugLevel, level, string message ) : void
level DebugLevel,
message string
Результат void

DestroyAll() публичный Метод

public DestroyAll ( bool localOnly ) : void
localOnly bool
Результат void

DestroyPlayerObjects() публичный Метод

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
Результат void

Disconnect() публичный Метод

Complete disconnect from photon (and the open master OR game server)
public Disconnect ( ) : void
Результат void

ExecuteRpc() защищенный Метод

Executes a received RPC event
protected ExecuteRpc ( ExitGames.Client.Photon.Hashtable rpcData, PhotonPlayer, sender ) : void
rpcData ExitGames.Client.Photon.Hashtable
sender PhotonPlayer,
Результат void

FetchInstantiationData() публичный Метод

public FetchInstantiationData ( int instantiationId ) : object[]
instantiationId int
Результат object[]

GetInstantiatedObjectsId() публичный Метод

This returns -1 if the GO could not be found in list of instantiatedObjects.
public GetInstantiatedObjectsId ( GameObject go ) : int
go GameObject
Результат int

GetMethod() защищенный статический Метод

protected static GetMethod ( MonoBehaviour monob, string methodType, MethodInfo &mi ) : bool
monob MonoBehaviour
methodType string
mi MethodInfo
Результат bool

GetPhotonView() публичный Метод

public GetPhotonView ( int viewID ) : PhotonView,
viewID int
Результат PhotonView,

GetPlayerWithId() защищенный Метод

protected GetPlayerWithId ( int number ) : PhotonPlayer,
number int
Результат PhotonPlayer,

GetRegions() публичный Метод

While on the NameServer, this gets you the list of regional servers (short names and their IPs to ping them).
public GetRegions ( ) : bool
Результат bool

LoadLevelIfSynced() защищенный Метод

Internally used to detect the current scene and load it if PhotonNetwork.automaticallySyncScene is enabled.
protected LoadLevelIfSynced ( ) : void
Результат void

LocalCleanPhotonView() публичный Метод

public LocalCleanPhotonView ( PhotonView, view ) : bool
view PhotonView,
Результат bool

LocalCleanupAnythingInstantiated() защищенный Метод

Cleans up anything that was instantiated in-game (not loaded with the scene).
protected LocalCleanupAnythingInstantiated ( bool destroyInstantiatedGameObjects ) : void
destroyInstantiatedGameObjects bool
Результат void

NetworkingPeer() публичный Метод

public NetworkingPeer ( string playername, ConnectionProtocol connectionProtocol ) : System.Linq
playername string
connectionProtocol ConnectionProtocol
Результат System.Linq

NewSceneLoaded() публичный Метод

public NewSceneLoaded ( ) : void
Результат void

OnEvent() публичный Метод

public OnEvent ( EventData, photonEvent ) : void
photonEvent EventData,
Результат void

OnOperationResponse() публичный Метод

public OnOperationResponse ( OperationResponse operationResponse ) : void
operationResponse OperationResponse
Результат void

OnStatusChanged() публичный Метод

public OnStatusChanged ( StatusCode statusCode ) : void
statusCode StatusCode
Результат void

OpCleanRpcBuffer() публичный Метод

Cleans server RPCs for PhotonView (without any further checks).
public OpCleanRpcBuffer ( PhotonView, view ) : void
view PhotonView,
Результат void

OpCleanRpcBuffer() публичный Метод

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
Результат void

OpCreateGame() публичный Метод

NetworkingPeer.OpCreateGame
public OpCreateGame ( EnterRoomParams, enterRoomParams ) : bool
enterRoomParams EnterRoomParams,
Результат bool

OpFindFriends() публичный Метод

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).
Результат bool

OpJoinRandomRoom() публичный Метод

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,
Результат bool

OpJoinRoom() публичный Метод

NetworkingPeer.OpJoinRoom
public OpJoinRoom ( EnterRoomParams, opParams ) : bool
opParams EnterRoomParams,
Результат bool

OpLeave() публичный Метод

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
Результат bool

OpRaiseEvent() публичный Метод

public OpRaiseEvent ( byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions, raiseEventOptions ) : bool
eventCode byte
customEventContent object
sendReliable bool
raiseEventOptions RaiseEventOptions,
Результат bool

OpRemoveCompleteCache() публичный Метод

public OpRemoveCompleteCache ( ) : void
Результат void

OpRemoveCompleteCacheOfPlayer() публичный Метод

Instead removing RPCs or Instantiates, this removed everything cached by the actor.
public OpRemoveCompleteCacheOfPlayer ( int actorNumber ) : void
actorNumber int
Результат void

RegisterPhotonView() публичный Метод

public RegisterPhotonView ( PhotonView, netView ) : void
netView PhotonView,
Результат void

RemoveInstantiatedGO() защищенный Метод

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.
Результат void

RemoveRPCsInGroup() публичный Метод

public RemoveRPCsInGroup ( int group ) : void
group int
Результат void

RequestOwnership() защищенный Метод

protected RequestOwnership ( int viewID, int fromOwner ) : void
viewID int
fromOwner int
Результат void

RunViewUpdate() публичный Метод

public RunViewUpdate ( ) : void
Результат void

SendMonoMessage() публичный статический Метод

public static SendMonoMessage ( PhotonNetworkingMessage methodString ) : void
methodString PhotonNetworkingMessage
Результат void

SetApp() публичный Метод

public SetApp ( string appId, string gameVersion ) : void
appId string
gameVersion string
Результат void

SetLevelInPropsIfSynced() защищенный Метод

protected SetLevelInPropsIfSynced ( object levelId ) : void
levelId object
Результат void

SetLevelPrefix() публичный Метод

public SetLevelPrefix ( short prefix ) : void
prefix short
Результат void

SetMasterClient() публичный Метод

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
Результат bool

SetMasterClient() защищенный Метод

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
Результат bool

SetReceivingEnabled() публичный Метод

public SetReceivingEnabled ( int group, bool enabled ) : void
group int
enabled bool
Результат void

SetReceivingEnabled() публичный Метод

public SetReceivingEnabled ( int enableGroups, int disableGroups ) : void
enableGroups int
disableGroups int
Результат void

SetSendingEnabled() публичный Метод

public SetSendingEnabled ( int group, bool enabled ) : void
group int
enabled bool
Результат void

SetSendingEnabled() публичный Метод

public SetSendingEnabled ( int enableGroups, int disableGroups ) : void
enableGroups int
disableGroups int
Результат void

TransferOwnership() защищенный Метод

protected TransferOwnership ( int viewID, int playerID ) : void
viewID int
playerID int
Результат void

UpdateMasterClient() защищенный Метод

Call when the server provides a MasterClientId (due to joining or the current MC leaving, etc).
protected UpdateMasterClient ( ) : void
Результат void

UpdatedActorList() защищенный Метод

protected UpdatedActorList ( int actorsInRoom ) : void
actorsInRoom int
Результат void

WebRpc() публичный Метод

public WebRpc ( string uriPath, object parameters ) : bool
uriPath string
parameters object
Результат bool

Описание свойств

IsInitialConnect публичное свойство

public bool IsInitialConnect
Результат bool

LobbyStatistics защищенное свойство

protected List LobbyStatistics
Результат List

PrefabCache публичное статическое свойство

public static Dictionary PrefabCache
Результат GameObject>.Dictionary

UsePrefabCache публичное статическое свойство

public static bool UsePrefabCache
Результат bool

currentLevelPrefix защищенное свойство

protected short currentLevelPrefix
Результат short

hasSwitchedMC публичное свойство

public bool hasSwitchedMC
Результат bool

insideLobby публичное свойство

public bool insideLobby
Результат bool

loadingLevelAndPausedNetwork защищенное свойство

Internally used to flag if the message queue was disabled by a "scene sync" situation (to re-enable it).
protected bool loadingLevelAndPausedNetwork
Результат bool

mActors публичное свойство

public Dictionary mActors
Результат PhotonPlayer>.Dictionary

mAppId защищенное свойство

Contains the AppId for the Photon Cloud (ignored by Photon Servers).
protected string mAppId
Результат string

mGameList публичное свойство

public Dictionary mGameList
Результат RoomInfo>.Dictionary

mGameListCopy публичное свойство

public RoomInfo[], mGameListCopy
Результат RoomInfo[],

mOtherPlayerListCopy публичное свойство

public PhotonPlayer[], mOtherPlayerListCopy
Результат PhotonPlayer[],

mPlayerListCopy публичное свойство

public PhotonPlayer[], mPlayerListCopy
Результат PhotonPlayer[],

photonViewList защищенное свойство

protected Dictionary photonViewList
Результат PhotonView>.Dictionary