Photon Server API Documentation v5.0RC1

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties | List of all members
Photon.LoadBalancing.MasterServer.MasterClientPeer Class Reference
Inheritance diagram for Photon.LoadBalancing.MasterServer.MasterClientPeer:
Photon.SocketServer.Rpc.Peer Photon.LoadBalancing.MasterServer.Lobby.ILobbyPeer Photon.Common.Authentication.ICustomAuthPeer Photon.Common.Authentication.IAuthTimeoutCheckerClient Photon.SocketServer.ClientPeer Photon.SocketServer.PeerBase

Public Member Functions

 MasterClientPeer (InitRequest initRequest)
 
OperationResponse HandleAuthenticate (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleJoinLobby (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleLeaveLobby (OperationRequest operationRequest)
 
virtual OperationResponse HandleCreateGame (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleFindFriends (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleJoinGame (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleJoinRandomGame (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleLobbyStatsRequest (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleRpcRequest (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleSettingsRequest (OperationRequest operationRequest, SendParameters sendParameters)
 
virtual OperationResponse HandleGetGameList (OperationRequest operationRequest, SendParameters sendParameters)
 
void IncTotalSuccessfulJoinRequest ()
 
void IncConcurrentJoinRequest (int delta)
 
object GetEncryptedTokenForGSAndGame (string gs, string gameId)
 
virtual void OnCustomAuthenticationError (ErrorCode errorCode, string debugMessage, IAuthenticateRequest authenticateRequest, SendParameters sendParameters)
 
virtual void OnCustomAuthenticationResult (CustomAuthenticationResult customAuthResult, IAuthenticateRequest authenticateRequest, SendParameters sendParameters, object state)
 
virtual void OnAuthTimeout (byte authOpCode)
 
- Public Member Functions inherited from Photon.SocketServer.Rpc.Peer
void SetCurrentOperationHandler (IOperationHandler operationHandler)
 Sets CurrentOperationHandler. More...
 
- Public Member Functions inherited from Photon.SocketServer.ClientPeer
void Trace (bool enabled, string tag)
 
new void GetTraceStatus (out int traceOptions, out int enableOptions, out string tag)
 
void TraceIfEnabledInConnect (string tag)
 Starts tracing if client connected with PeerId 0xFFFE to signal it wants to be traced (e.g. reconnect after an unexpected disconnect) More...
 
- Public Member Functions inherited from Photon.SocketServer.PeerBase
void Initialize (InitRequest initRequest)
 
override string ToString ()
 
void Disconnect (int disconnectError=ErrorCodes.Ok)
 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...
 
bool SetupEncryption (EncryptionData encryptionData, byte channelCount, out short errorCode, out string errorMsg)
 
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...
 
SendResult SendDisconnectMessage (DisconnectMessage message, SendParameters sendParameters, int disconnectDelay=DefaultDisconnectInterval)
 
void GetStats (out int roundTripTime, out int roundTripTimeVariance, out int numFailures)
 
void SetDebugString (string message)
 
string GetDebugString ()
 
virtual string GetHistograms ()
 
SendResult SendEventAndDisconnect (IEventData eventData, SendParameters sendParameters, int disconnectDelay=DefaultDisconnectInterval, int disconnectCode=ErrorCodes.Ok)
 
SendResult SendMessageAndDisconnect (object message, SendParameters sendParameters, int disconnectDelay=DefaultDisconnectInterval, int disconnectCode=ErrorCodes.Ok)
 
SendResult SendOperationResponseAndDisconnect (OperationResponse operationResponse, SendParameters sendParameters, int disconnectDelay=DefaultDisconnectInterval)
 Sends the operation response to the client. More...
 
void ScheduleDisconnect (int disconnectError, int delay)
 Schedules disconnect for peer. After this call data will be neither accepted from nor sent to client one of use cases is next: send error info and schedule for disconnect. this will give a chance to error information to reach a client More...
 
int GetLastTouch ()
 
void SetPrivateCustomTypeCache (CustomTypeCache cache)
 Sets private custom type cache. It is supposed to be used together with plugins. In other case Protocol.TryRegisterCustomType should be used More...
 
void SetInboundController (InboundController controller)
 
void Dispose ()
 Disposes the peer. More...
 
void Trace (bool enabled, object tag)
 

Public Attributes

string SessionId => this.unencryptedAuthToken.SessionId
 
bool CustomAuthUserIdUsed => this.unencryptedAuthToken?.CustomAuthUserIdUsed ?? false
 
bool UseHostnames => this.IsIPv6ToIPv4Bridged
 
virtual bool AllowCreateJoinActivity
 
IFiber Fiber => this.RequestFiber
 
- Public Attributes inherited from Photon.SocketServer.PeerBase
bool Connected => this.ConnectionState == ConnectionState.Connected || this.connectionState == ConnectionState.ScheduledForDisconnect
 Gets a value indicating whether this PeerBase instance is connected. More...
 
int ConnectionId => this.UnmanagedPeer.GetConnectionID()
 Gets the connection id. More...
 
bool IsConnectionSecure => this.datagramEncryptionUsed || this.NetworkProtocol == NetworkProtocolType.SecureWebSocket
 
bool Disposed => this.ConnectionState == ConnectionState.Disposed
 Gets a value indicating whether the peer was disposed. More...
 
bool ScheduledForDisconnect => this.connectionState == ConnectionState.ScheduledForDisconnect
 
IPAddress LocalIPAddress => string.IsNullOrEmpty(this.LocalIP) ? IPAddress.None : IPAddress.Parse(this.LocalIP)
 Gets the IP Address the client connects to. More...
 
IPAddress RemoteIPAddress => string.IsNullOrEmpty(this.RemoteIP) ? IPAddress.None : IPAddress.Parse(this.RemoteIP)
 Gets the client's remote IP address. More...
 
IFiber RequestFiber => this.requestFiber
 Gets fiber for incoming messages. More...
 
bool LocalIPAddressIsIPv6 => this.LocalIPAddress.AddressFamily == AddressFamily.InterNetworkV6
 If true connection is using a server IPv6 endpoint. More...
 
bool IsIPv6ToIPv4Bridged => this.SourceUsingIPv6 && this.LocalIPAddress.AddressFamily != AddressFamily.InterNetworkV6
 If true the client is being bridged (DNS64+NAT64), also SourceUsingIPv6. More...
 
ProtocolType ProtocolType => this.protocol.ProtocolType
 

Protected Member Functions

 MasterClientPeer (InitRequest initRequest, bool derived)
 
override void OnDisconnect (int reasonCode, string reasonDetail)
 Executed when a peer disconnects. This method is being enqueued to the fiber. More...
 
void LeaveLobby ()
 
virtual object GetEncryptedAuthenticationToken (AuthenticateRequest request)
 
object GetEncryptedAuthToken (MasterApplication app)
 
virtual void CreateAuthTokenAndSendResponse (CustomAuthenticationResult customAuthResult, AuthenticateRequest authRequest, SendParameters sendParameters, AuthSettings authSettings, OperationResponse operationResponse)
 
- Protected Member Functions inherited from Photon.SocketServer.Rpc.Peer
 Peer (InitRequest initRequest)
 Initializes a new instance of the Peer class. More...
 
- 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...
 
void OnMessageInternal (object message, SendParameters sendParameters)
 
void OnOperationRequestInternal (OperationRequest operationRequest, SendParameters sendParameters)
 
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 OnDeserializationError (byte[] data, RtsMessageType msgType, string debugMessage, short errorCode=ErrorCodes.UnexpectedData, byte opCode=0, Exception exception=null)
 This method is called if incoming data has an unexpected format. Per default this method disconnects the client. Override to change this behavior. More...
 
OperationRequest ParseOperationRequest (byte[] data, SendParameters sendParameters)
 
OperationRequest ParseInternalOperationRequest (byte[] data, SendParameters sendParameters)
 
object ParseMessage (byte[] data, SendParameters sendParameters)
 
byte[] ParseRawMessage (byte[] data, SendParameters sendParameters)
 
void HandleParseError (byte[] data, SendParameters sendParameters, Exception exception, string errorMsg, short errorCode, RtsMessageType msgType, byte operationCode=0)
 
void GetTraceStatus (out int traceOptions, out int enableOptions, out string tag)
 
void DisconnectAfterSend (int disconnectCode, int disconnectDelay, SendResult result)
 
virtual void OnEncryptionQueueOverload (EncryptionQueueFailureParams failureParams)
 

Protected Attributes

AuthenticationToken unencryptedAuthToken
 
readonly bool authOnceUsed
 
readonly bool binaryTokenUsed
 
int concurrentJoinRequests
 
int totalSuccessfulJoinResponses
 
int NumberAuthRequests
 
int MaxNumberAuthRequests = 3
 
- Protected Attributes inherited from Photon.SocketServer.PeerBase
readonly object SyncRoot = new object()
 object for synchronization More...
 
CustomTypeCache privateCustomTypeCache
 
PeerMetaDataContext metaDataContext
 

Static Protected Attributes

static readonly LogCountGuard canNotDecryptToken = new LogCountGuard(new TimeSpan(0, 1, 0))
 
- Static Protected Attributes inherited from Photon.SocketServer.PeerBase
static readonly ILogger sendErrorLog = LogManager.GetLogger("Photon.ErrorLog.PeerSendError")
 

Properties

string UserId [get, set]
 
virtual GameApplication Application [get, set]
 
IGameListSubscriptionGameChannelSubscription [set]
 
WebRpcHandler WebRpcHandler [set]
 
NetworkProtocolType ExpectedProtocol [get, protected set]
 
int MaxPropertiesSizePerRequest = MasterServerSettings.Default.Limits.Inbound.MaxPropertiesSizePerRequest [get, protected set]
 
bool AllowDebugGameOperation = CommonSettings.Default.AllowDebugGameOperation [get, protected set]
 
IDisposable AuthTimeoutTimer [get, set]
 
- Properties inherited from Photon.SocketServer.Rpc.Peer
IOperationHandler CurrentOperationHandler [get]
 Gets the current IOperationHandler. OnOperationRequest and OnDisconnect calls the CurrentOperationHandler. More...
 
- Properties inherited from Photon.SocketServer.PeerBase
ConnectionState ConnectionState [get, set]
 Gets the ConnectionState for this instance. More...
 
string LocalIP [get]
 Gets the IP 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...
 
int RemotePort [get]
 Gets the port the client connects from. 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 SourceUsingIPv6 [get]
 If true the peer is using IPv6 to connect to the server, if the server endpoint used is not IPv6 (LocalIPAddressIsIPv6) it means the client is being bridged (DNS64+NAT64), also IsIPv6ToIPv4Bridged. More...
 
bool ClientUsingDebugLib [get]
 
byte SdkId [get]
 
byte PlatformId [get]
 
Version ClientVersion [get, protected set]
 
DateTime CreationTime = DateTime.Now [get]
 
PeerType PeerType [get]
 Under laying native peer type More...
 
InboundController PrivateInboundController [get]
 
int LastErrorCode [get]
 last error code that we was sent/set though this peer More...
 
- Properties inherited from Photon.LoadBalancing.MasterServer.Lobby.ILobbyPeer
NetworkProtocolType NetworkProtocol [get]
 
IPAddress LocalIPAddress [get]
 
int LocalPort [get]
 
string UserId [get]
 
bool UseHostnames [get]
 
string SessionId [get]
 
bool CustomAuthUserIdUsed [get]
 
- Properties inherited from Photon.Common.Authentication.ICustomAuthPeer
int ConnectionId [get]
 
string UserId [get, set]
 
- Properties inherited from Photon.Common.Authentication.IAuthTimeoutCheckerClient
IDisposable AuthTimeoutTimer [get, set]
 
IFiber Fiber [get]
 

Additional Inherited Members

- Static Public Attributes inherited from Photon.SocketServer.PeerBase
const int DefaultDisconnectInterval = 5_000
 
- Static Protected Member Functions inherited from Photon.SocketServer.PeerBase
static bool NeedSendErrorLog (SendResult sendResult)
 

Constructor & Destructor Documentation

◆ MasterClientPeer() [1/2]

Photon.LoadBalancing.MasterServer.MasterClientPeer.MasterClientPeer ( InitRequest  initRequest)
inline

◆ MasterClientPeer() [2/2]

Photon.LoadBalancing.MasterServer.MasterClientPeer.MasterClientPeer ( InitRequest  initRequest,
bool  derived 
)
inlineprotected

Member Function Documentation

◆ CreateAuthTokenAndSendResponse()

virtual void Photon.LoadBalancing.MasterServer.MasterClientPeer.CreateAuthTokenAndSendResponse ( CustomAuthenticationResult  customAuthResult,
AuthenticateRequest  authRequest,
SendParameters  sendParameters,
AuthSettings  authSettings,
OperationResponse  operationResponse 
)
inlineprotectedvirtual

◆ GetEncryptedAuthenticationToken()

virtual object Photon.LoadBalancing.MasterServer.MasterClientPeer.GetEncryptedAuthenticationToken ( AuthenticateRequest  request)
inlineprotectedvirtual

◆ GetEncryptedAuthToken()

object Photon.LoadBalancing.MasterServer.MasterClientPeer.GetEncryptedAuthToken ( MasterApplication  app)
inlineprotected

◆ GetEncryptedTokenForGSAndGame()

object Photon.LoadBalancing.MasterServer.MasterClientPeer.GetEncryptedTokenForGSAndGame ( string  gs,
string  gameId 
)
inline

◆ HandleAuthenticate()

OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleAuthenticate ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inline

◆ HandleCreateGame()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleCreateGame ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleFindFriends()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleFindFriends ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleGetGameList()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleGetGameList ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleJoinGame()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleJoinGame ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleJoinLobby()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleJoinLobby ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleJoinRandomGame()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleJoinRandomGame ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleLeaveLobby()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleLeaveLobby ( OperationRequest  operationRequest)
inlinevirtual

◆ HandleLobbyStatsRequest()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleLobbyStatsRequest ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleRpcRequest()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleRpcRequest ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ HandleSettingsRequest()

virtual OperationResponse Photon.LoadBalancing.MasterServer.MasterClientPeer.HandleSettingsRequest ( OperationRequest  operationRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ IncConcurrentJoinRequest()

void Photon.LoadBalancing.MasterServer.MasterClientPeer.IncConcurrentJoinRequest ( int  delta)
inline

◆ IncTotalSuccessfulJoinRequest()

void Photon.LoadBalancing.MasterServer.MasterClientPeer.IncTotalSuccessfulJoinRequest ( )
inline

◆ LeaveLobby()

void Photon.LoadBalancing.MasterServer.MasterClientPeer.LeaveLobby ( )
inlineprotected

◆ OnAuthTimeout()

virtual void Photon.LoadBalancing.MasterServer.MasterClientPeer.OnAuthTimeout ( byte  authOpCode)
inlinevirtual

◆ OnCustomAuthenticationError()

virtual void Photon.LoadBalancing.MasterServer.MasterClientPeer.OnCustomAuthenticationError ( ErrorCode  errorCode,
string  debugMessage,
IAuthenticateRequest  authenticateRequest,
SendParameters  sendParameters 
)
inlinevirtual

◆ OnCustomAuthenticationResult()

virtual void Photon.LoadBalancing.MasterServer.MasterClientPeer.OnCustomAuthenticationResult ( CustomAuthenticationResult  customAuthResult,
IAuthenticateRequest  authenticateRequest,
SendParameters  sendParameters,
object  state 
)
inlinevirtual

◆ OnDisconnect()

override void Photon.LoadBalancing.MasterServer.MasterClientPeer.OnDisconnect ( int  reasonCode,
string  reasonDetail 
)
inlineprotectedvirtual

Executed when a peer disconnects. This method is being enqueued to the fiber.

Reimplemented from Photon.SocketServer.Rpc.Peer.

Member Data Documentation

◆ AllowCreateJoinActivity

virtual bool Photon.LoadBalancing.MasterServer.MasterClientPeer.AllowCreateJoinActivity
Initial value:
=>
this.concurrentJoinRequests <= MasterServerSettings.Default.Limits.Inbound.MaxConcurrentJoinRequests
&& this.totalSuccessfulJoinResponses <= MasterServerSettings.Default.Limits.Inbound.MaxTotalJoinRequests

◆ authOnceUsed

readonly bool Photon.LoadBalancing.MasterServer.MasterClientPeer.authOnceUsed
protected

◆ binaryTokenUsed

readonly bool Photon.LoadBalancing.MasterServer.MasterClientPeer.binaryTokenUsed
protected

◆ canNotDecryptToken

readonly LogCountGuard Photon.LoadBalancing.MasterServer.MasterClientPeer.canNotDecryptToken = new LogCountGuard(new TimeSpan(0, 1, 0))
staticprotected

◆ concurrentJoinRequests

int Photon.LoadBalancing.MasterServer.MasterClientPeer.concurrentJoinRequests
protected

◆ CustomAuthUserIdUsed

bool Photon.LoadBalancing.MasterServer.MasterClientPeer.CustomAuthUserIdUsed => this.unencryptedAuthToken?.CustomAuthUserIdUsed ?? false

◆ Fiber

IFiber Photon.LoadBalancing.MasterServer.MasterClientPeer.Fiber => this.RequestFiber

◆ MaxNumberAuthRequests

int Photon.LoadBalancing.MasterServer.MasterClientPeer.MaxNumberAuthRequests = 3
protected

◆ NumberAuthRequests

int Photon.LoadBalancing.MasterServer.MasterClientPeer.NumberAuthRequests
protected

◆ SessionId

string Photon.LoadBalancing.MasterServer.MasterClientPeer.SessionId => this.unencryptedAuthToken.SessionId

◆ totalSuccessfulJoinResponses

int Photon.LoadBalancing.MasterServer.MasterClientPeer.totalSuccessfulJoinResponses
protected

◆ unencryptedAuthToken

AuthenticationToken Photon.LoadBalancing.MasterServer.MasterClientPeer.unencryptedAuthToken
protected

◆ UseHostnames

bool Photon.LoadBalancing.MasterServer.MasterClientPeer.UseHostnames => this.IsIPv6ToIPv4Bridged

Property Documentation

◆ AllowDebugGameOperation

bool Photon.LoadBalancing.MasterServer.MasterClientPeer.AllowDebugGameOperation = CommonSettings.Default.AllowDebugGameOperation
getprotected set

◆ Application

virtual GameApplication Photon.LoadBalancing.MasterServer.MasterClientPeer.Application
getsetprotected

◆ AuthTimeoutTimer

IDisposable Photon.LoadBalancing.MasterServer.MasterClientPeer.AuthTimeoutTimer
getset

◆ ExpectedProtocol

NetworkProtocolType Photon.LoadBalancing.MasterServer.MasterClientPeer.ExpectedProtocol
getprotected set

◆ GameChannelSubscription

IGameListSubscription? Photon.LoadBalancing.MasterServer.MasterClientPeer.GameChannelSubscription
set

◆ MaxPropertiesSizePerRequest

int Photon.LoadBalancing.MasterServer.MasterClientPeer.MaxPropertiesSizePerRequest = MasterServerSettings.Default.Limits.Inbound.MaxPropertiesSizePerRequest
getprotected set

◆ UserId

string Photon.LoadBalancing.MasterServer.MasterClientPeer.UserId
getset

◆ WebRpcHandler

WebRpcHandler Photon.LoadBalancing.MasterServer.MasterClientPeer.WebRpcHandler
set
Photon.LoadBalancing.MasterServer.MasterClientPeer.totalSuccessfulJoinResponses
int totalSuccessfulJoinResponses
Definition: MasterClientPeer.cs:79
Photon.LoadBalancing.MasterServer.MasterClientPeer.concurrentJoinRequests
int concurrentJoinRequests
Definition: MasterClientPeer.cs:78