Photon Server API
Classes | Public Member Functions | Protected Member Functions | Properties | List of all members
Photon.Hive.HivePeer Class Reference

Inheritance class of PeerBase. The LitePeer dispatches incoming OperationRequests at OnOperationRequest. When joining a Room a Caching.RoomReference is stored in the RoomReference property. An IFiber guarantees that all outgoing messages (events/operations) are sent one after the other. More...

Inheritance diagram for Photon.Hive.HivePeer:
Photon.SocketServer.ClientPeer Photon.SocketServer.PeerBase Photon.Hive.Tests.TestHivePeer Photon.LoadBalancing.GameServer.GameClientPeer

Classes

class  JoinStages
 

Public Member Functions

 HivePeer (InitRequest request)
 Initializes a new instance of the HivePeer class. More...
 
bool ValidateOperation (Operation operation, SendParameters sendParameters)
 Checks if a operation is valid. If the operation is not valid an operation response containing a desciptive error message will be sent to the peer. More...
 
void RemovePeerFromCurrentRoom (int reason, string detail)
 Checks if the the state of peer is set to a reference of a room. If a room refrence is present the peer will be removed from the related room and the reference will be disposed. Disposing the reference allows the associated room factory to remove the room instance if no more references to the room exists. More...
 
void ReleaseRoomReference ()
 
void OnJoinFailed (ErrorCode result, string details)
 
virtual bool IsThisSameSession (HivePeer peer)
 
void ScheduleDisconnect (int time=1000)
 
- Public Member Functions inherited from Photon.SocketServer.PeerBase
void Initialize (InitRequest initRequest)
 
override string ToString ()
 
void Disconnect ()
 Closes the connection. More...
 
void AbortConnection ()
 Forces the connection to close immediately. Should only be used if "Disconnect" does not lead to a clean connection shutdown, e.g. in case of an overloaded connection. More...
 
void Flush ()
 Flushes all pending data to the socket. More...
 
byte[] InitializeEncryption (byte[] otherPartyPublicKey)
 Initializes the peer to receive and send encrypted operations with EncryptionMethod.Sha256Pkcs7. More...
 
byte[] InitializeEncryption (byte[] otherPartyPublicKey, EncryptionMethod mode)
 Initializes the peer to receive and send encrypted operations. More...
 
SendResult SendEvent (IEventData eventData, SendParameters sendParameters)
 Sends an IEventData object to the client. More...
 
SendResult SendMessage (object message, SendParameters sendParameters)
 
SendResult SendOperationResponse (OperationResponse operationResponse, SendParameters sendParameters)
 Sends the operation response to the client. More...
 
void GetStats (out int roundTripTime, out int roundTripTimeVariance, out int numFailures)
 
void SetDebugString (string message)
 
int GetLastTouch ()
 
void SetPrivateCustomTypeCache (CustomTypeCache cache)
 Sets private custom type cache. It is supposed to be used together with plugins. In other case Proptocol.TryRegisterCustomType should be used More...
 
void Dispose ()
 Disposes the peer. More...
 

Protected Member Functions

virtual RoomReference GetRoomReference (JoinGameRequest joinRequest, params object[] args)
 Called by HandleJoinOperation to get a room reference for a join operations. This method can be overloaded by inheritors to provide custom room references. More...
 
virtual void HandleCreateGameOperation (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual void HandleGameOperation (OperationRequest operationRequest, SendParameters sendParameters)
 Enqueues game related operation requests in the peers current game. More...
 
virtual void HandleJoinGameOperation (OperationRequest operationRequest, SendParameters sendParameters)
 Handles the JoinGameRequest to enter a HiveGame. This method removes the peer from any previously joined room, finds the room intended for join and enqueues the operation for it to handle. More...
 
virtual PluginTraits GetPluginTraits ()
 
virtual void HandleJoinOperation (OperationRequest operationRequest, SendParameters sendParameters)
 Handles the JoinGameRequest to enter a HiveGame. This method removes the peer from any previously joined room, finds the room intended for join and enqueues the operation for it to handle. More...
 
virtual void HandleLeaveOperation (OperationRequest operationRequest, SendParameters sendParameters)
 Handles the LeaveRequest to leave a HiveGame. More...
 
virtual void HandlePingOperation (OperationRequest operationRequest, SendParameters sendParameters)
 Handles a ping operation. More...
 
override void OnDisconnect (DisconnectReason reasonCode, string reasonDetail)
 Called when client disconnects. Ensures that disconnected players leave the game Room. The player is not removed immediately but a message is sent to the room. This avoids threading issues by making sure the player remove is not done concurrently with operations. More...
 
override void OnOperationRequest (OperationRequest operationRequest, SendParameters sendParameters)
 Called when the client sends an OperationRequest. More...
 
virtual RoomReference GetOrCreateRoom (string gameId, params object[] args)
 
virtual bool TryCreateRoom (string gameId, out RoomReference roomReference, params object[] args)
 
virtual bool TryGetRoomReference (string gameId, out RoomReference roomReference)
 
virtual bool TryGetRoomWithoutReference (string gameId, out Room room)
 
virtual void OnRoomNotFound (string gameId)
 
- Protected Member Functions inherited from Photon.SocketServer.ClientPeer
 ClientPeer (InitRequest initRequest)
 
- Protected Member Functions inherited from Photon.SocketServer.PeerBase
virtual SendResult SendData (byte[] data, SendParameters sendParameters)
 Sends bytes to the client. More...
 
virtual void OnReceive (byte[] data, SendParameters sendParameters)
 Invoked if incoming data was received for the peer. More...
 
virtual void Dispose (bool disposing)
 Disposes the internal fibers. More...
 
virtual void OnSendBufferEmpty ()
 The default behavior of OnSendBufferFull is to disconnect the client. If this behavior is changed (override) the inheritor can pause sending until OnSendBufferEmpty is called. More...
 
virtual void OnUnexpectedDataReceived (byte[] data, string debugMessage)
 This method is called if incoming data has an unexpected format. Per default this method disconnects the client. Override to change this behavior. More...
 

Properties

RoomReference RoomReference [get, set]
 Gets or sets a Caching.RoomReference when joining a Room. More...
 
string UserId [get, protected set]
 
WebRpcHandler WebRpcHandler [get, set]
 
Dictionary< string, object > AuthCookie [get, protected set]
 
AuthenticationToken AuthToken [get, protected set]
 
int HttpRpcCallsLimit [get, protected set]
 
- Properties inherited from Photon.SocketServer.PeerBase
ConnectionState ConnectionState [get, set]
 Gets the ConnectionState for this instance. More...
 
bool Connected [get]
 Gets a value indicating whether this PeerBase instance is connected. More...
 
int ConnectionId [get]
 Gets the connection id. More...
 
bool Disposed [get]
 Gets a value indicating whether the peer was disposed. More...
 
string LocalIP [get]
 Gets the IP the client connects to. More...
 
IPAddress LocalIPAddress [get]
 Gets the IP Address the client connects to. More...
 
int LocalPort [get]
 Gets the port the client connects to. More...
 
NetworkProtocolType NetworkProtocol [get]
 Gets the network protocol type used by the peer. More...
 
IRpcProtocol Protocol [get, set]
 Gets the used IRpcProtocol protocol. More...
 
string RemoteIP [get]
 Gets the client's remote IP address. More...
 
IPAddress RemoteIPAddress [get]
 Gets the client's remote IP address. More...
 
int RemotePort [get]
 Gets the port the client connects from. More...
 
IFiber RequestFiber [get]
 Gets fiber for incoming messages. More...
 
int RoundTripTime [get, protected set]
 Gets the last round trip time for this peer. More...
 
int RoundTripTimeVariance [get, protected set]
 Gets the last round trip time variance for this peer. More...
 
int NumFailures [get, protected set]
 
bool LocalIPAddressIsIPv6 [get]
 If true connection is using a server IPv6 endpoint. More...
 
bool SourceUsingIPv6 [get]
 If true the peer is using IPv6 to connect to the server, if the server enpoint used is not IPv6 (LocalIPAddressIsIPv6) it means the client is beeing bridged (DNS64+NAT64), also IsIPv6ToIPv4Bridged. More...
 
bool IsIPv6ToIPv4Bridged [get]
 If true the client is beeing bridged (DNS64+NAT64), also SourceUsingIPv6. More...
 

Detailed Description

Inheritance class of PeerBase. The LitePeer dispatches incoming OperationRequests at OnOperationRequest. When joining a Room a Caching.RoomReference is stored in the RoomReference property. An IFiber guarantees that all outgoing messages (events/operations) are sent one after the other.

Constructor & Destructor Documentation

Photon.Hive.HivePeer.HivePeer ( InitRequest  request)
inline

Initializes a new instance of the HivePeer class.

Member Function Documentation

virtual RoomReference Photon.Hive.HivePeer.GetOrCreateRoom ( string  gameId,
params object[]  args 
)
inlineprotectedvirtual
virtual PluginTraits Photon.Hive.HivePeer.GetPluginTraits ( )
inlineprotectedvirtual
virtual RoomReference Photon.Hive.HivePeer.GetRoomReference ( JoinGameRequest  joinRequest,
params object[]  args 
)
inlineprotectedvirtual

Called by HandleJoinOperation to get a room reference for a join operations. This method can be overloaded by inheritors to provide custom room references.

Parameters
joinRequestThe join request.
argsmore arguments in order to create room
Returns
An Caching.RoomReference instance.

Reimplemented in Photon.Hive.Tests.TestHivePeer, and Photon.LoadBalancing.GameServer.GameClientPeer.

virtual void Photon.Hive.HivePeer.HandleCreateGameOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual
virtual void Photon.Hive.HivePeer.HandleGameOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Enqueues game related operation requests in the peers current game.

Parameters
operationRequestThe operation request.
sendParametersThe send Parameters.

The current for a peer is stored in the peers state property. Using the Room.EnqueueOperation method ensures that all operation request dispatch logic has thread safe access to all room instance members since they are processed in a serial order.

Inheritors can use this method to enqueue there custom game operation to the peers current game.

virtual void Photon.Hive.HivePeer.HandleJoinGameOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Handles the JoinGameRequest to enter a HiveGame. This method removes the peer from any previously joined room, finds the room intended for join and enqueues the operation for it to handle.

Parameters
operationRequestThe operation request to handle.
sendParametersThe send Parameters.
virtual void Photon.Hive.HivePeer.HandleJoinOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Handles the JoinGameRequest to enter a HiveGame. This method removes the peer from any previously joined room, finds the room intended for join and enqueues the operation for it to handle.

Parameters
operationRequestThe operation request to handle.
sendParametersThe send Parameters.
virtual void Photon.Hive.HivePeer.HandleLeaveOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Handles the LeaveRequest to leave a HiveGame.

Parameters
operationRequestThe operation request to handle.
sendParametersThe send Parameters.
virtual void Photon.Hive.HivePeer.HandlePingOperation ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Handles a ping operation.

Parameters
operationRequestThe operation request to handle.
sendParametersThe send Parameters.
virtual bool Photon.Hive.HivePeer.IsThisSameSession ( HivePeer  peer)
inlinevirtual
override void Photon.Hive.HivePeer.OnDisconnect ( DisconnectReason  reasonCode,
string  reasonDetail 
)
inlineprotectedvirtual

Called when client disconnects. Ensures that disconnected players leave the game Room. The player is not removed immediately but a message is sent to the room. This avoids threading issues by making sure the player remove is not done concurrently with operations.

Implements Photon.SocketServer.PeerBase.

Reimplemented in Photon.Hive.Tests.TestHivePeer.

void Photon.Hive.HivePeer.OnJoinFailed ( ErrorCode  result,
string  details 
)
inline
override void Photon.Hive.HivePeer.OnOperationRequest ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Called when the client sends an OperationRequest.

Parameters
operationRequestThe operation request.
sendParametersThe send Parameters.

Implements Photon.SocketServer.PeerBase.

virtual void Photon.Hive.HivePeer.OnRoomNotFound ( string  gameId)
inlineprotectedvirtual
void Photon.Hive.HivePeer.ReleaseRoomReference ( )
inline
void Photon.Hive.HivePeer.RemovePeerFromCurrentRoom ( int  reason,
string  detail 
)
inline

Checks if the the state of peer is set to a reference of a room. If a room refrence is present the peer will be removed from the related room and the reference will be disposed. Disposing the reference allows the associated room factory to remove the room instance if no more references to the room exists.

void Photon.Hive.HivePeer.ScheduleDisconnect ( int  time = 1000)
inline
virtual bool Photon.Hive.HivePeer.TryCreateRoom ( string  gameId,
out RoomReference  roomReference,
params object[]  args 
)
inlineprotectedvirtual
virtual bool Photon.Hive.HivePeer.TryGetRoomReference ( string  gameId,
out RoomReference  roomReference 
)
inlineprotectedvirtual
virtual bool Photon.Hive.HivePeer.TryGetRoomWithoutReference ( string  gameId,
out Room  room 
)
inlineprotectedvirtual
bool Photon.Hive.HivePeer.ValidateOperation ( Operation  operation,
SendParameters  sendParameters 
)
inline

Checks if a operation is valid. If the operation is not valid an operation response containing a desciptive error message will be sent to the peer.

Parameters
operationThe operation.
sendParametersThe send Parameters.
Returns
true if the operation is valid; otherwise false.

Property Documentation

Dictionary<string, object> Photon.Hive.HivePeer.AuthCookie
getprotected set
AuthenticationToken Photon.Hive.HivePeer.AuthToken
getprotected set
int Photon.Hive.HivePeer.HttpRpcCallsLimit
getprotected set
RoomReference Photon.Hive.HivePeer.RoomReference
getset

Gets or sets a Caching.RoomReference when joining a Room.

string Photon.Hive.HivePeer.UserId
getprotected set
WebRpcHandler Photon.Hive.HivePeer.WebRpcHandler
getset