Photon Server API

Public Member Functions | Properties | List of all members
Photon.SocketServer.IRpcProtocol Interface Reference

The implementation class supports a specific real time server protocol. More...

Inherited by Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Protocol, Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteProtocol, Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteProtocolV16, Photon.SocketServer.Rpc.Protocols.GpBinaryByteV2.GpBinaryByteProtocolV16V2, Photon.SocketServer.Rpc.Protocols.GpBinaryV17.GpBinaryProtocolV17, and Photon.SocketServer.Rpc.Protocols.Json.JsonProtocol.

Public Member Functions

void Serialize (Stream stream, object obj, CustomTypeCache privateCustomTypeCache=null)
 Serialze an object to a stream More...
 
byte[] SerializeEventData (EventData eventData, CustomTypeCache privateCustomTypeCache=null)
 Serializes an EventData. More...
 
byte[] SerializeEventDataEncrypted (IEventData eventData, ICryptoProvider cryptoProvider, CustomTypeCache privateCustomTypeCache=null)
 Encrypts an EventData. More...
 
byte[] SerializeInitRequest (string appName, Version version, ushort sdkId, bool usingIPv6)
 Serialize an init request. More...
 
byte[] SerializeInitRequestV2 (string appName, string serverAddress, Version version, object custom)
 
byte[] SerializeInitResponse (object responseObject)
 Serialize an init response. More...
 
byte[] SerializeMessage (object message, CustomTypeCache privateCustomTypeCache=null)
 
byte[] SerializeMessageEncrypted (object message, ICryptoProvider cryptoProvider, CustomTypeCache privateCustomTypeCache=null)
 
byte[] SerializeRawMessage (byte[] message, CustomTypeCache privateCustomTypeCache=null)
 
byte[] SerializeRawMessageEncrypted (byte[] message, ICryptoProvider cryptoProvider, CustomTypeCache privateCustomTypeCache=null)
 
byte[] SerializeInternalOperationRequest (OperationRequest operationRequest)
 Serializes an internal OperationRequest. More...
 
byte[] SerializeInternalOperationResponse (OperationResponse operationResponse)
 Serialize an OperationResponse for system operations. More...
 
byte[] SerializeOperationRequest (OperationRequest operationRequest, CustomTypeCache privateCustomTypeCache=null)
 Serializes an OperationRequest More...
 
byte[] SerializeOperationRequestEncrypted (OperationRequest operationRequest, ICryptoProvider cryptoProvider, CustomTypeCache privateCustomTypeCache=null)
 Serializes an OperationRequest The operation request data will be encrypted using the specified ICryptoProvider. More...
 
byte[] SerializeOperationResponse (OperationResponse operationResponse, CustomTypeCache privateCustomTypeCache=null)
 Serializes an OperationResponse. More...
 
byte[] SerializeOperationResponseEncrypted (OperationResponse operationResponse, ICryptoProvider cryptoProvider, CustomTypeCache privateCustomTypeCache=null)
 Serializes an OperationResponse. The operation response data will be encrypted using the specified ICryptoProvider. More...
 
bool TryConvertParameter (ObjectMemberInfo< DataMemberAttribute > parameterInfo, ref object value)
 Since C# supports many more types than the used protocol some parameters need to be converted. This method tries to convert an operation request parameter into to a type that works for a target field or property. More...
 
bool TryParse (Stream stream, out object obj, CustomTypeCache privateCustomTypeCache=null)
 Try to parse an object from a stream. More...
 
bool TryParse (byte[] data, int startIndex, int length, out object value, CustomTypeCache privateCustomTypeCache=null)
 Try to parse an object from a byte array. More...
 
bool TryParseEncrypted (byte[] data, ICryptoProvider cryptoProvider, int startIndex, int length, out object value, CustomTypeCache privateCustomTypeCache=null)
 
bool TryParseEventData (byte[] data, out EventData eventData, CustomTypeCache privateCustomTypeCache=null)
 Tries to convert a byte array into an EventData instance. The data was serialized with IRpcProtocol.SerializeEventData. More...
 
bool TryParseEventDataEncrypted (byte[] data, ICryptoProvider cryptoProvider, out EventData eventData, CustomTypeCache privateCustomTypeCache=null)
 Tries to convert a byte array into an EventData instance. The data was serialized with IRpcProtocol.SerializeEventDataEncrypted. More...
 
bool TryParseMessageHeader (byte[] data, out RtsMessageHeader header)
 Tries to parse the header. More...
 
bool TryParseOperationRequest (byte[] data, out OperationRequest operationRequest, CustomTypeCache privateCustomTypeCache=null)
 Tries to convert a byte array into an OperationRequest instance. The data was serialized with IRpcProtocol.SerializeOperationRequest. More...
 
bool TryParseOperationRequestEncrypted (byte[] data, ICryptoProvider cryptoProvider, out OperationRequest operationRequest, CustomTypeCache privateCustomTypeCache)
 Tries to convert a byte array into an OperationRequest instance. The data was serialized with IRpcProtocol.SerializeOperationRequestEncrypted. More...
 
bool TryParseOperationResponse (byte[] data, out OperationResponse operationResponse, CustomTypeCache privateCustomTypeCache=null)
 Tries to convert a byte array into an OperationResponse instance. The data was serialized with IRpcProtocol.SerializeOperationResponse. More...
 
bool TryParseOperationResponseEncrypted (byte[] data, ICryptoProvider cryptoProvider, out OperationResponse operationResponse, CustomTypeCache privateCustomTypeCache=null)
 Tries to convert a byte array into an OperationResponse instance. The data was serialized with IRpcProtocol.SerializeOperationResponseEncrypted. More...
 

Properties

ProtocolType ProtocolType [get]
 Gets the type of the protocol. More...
 
int HeaderSize [get]
 Gets the size used for the protocol header. More...
 
MessageContentType MessageContentType [get]
 

Detailed Description

The implementation class supports a specific real time server protocol.

Member Function Documentation

◆ Serialize()

void Photon.SocketServer.IRpcProtocol.Serialize ( Stream  stream,
object  obj,
CustomTypeCache  privateCustomTypeCache = null 
)

Serialze an object to a stream

Parameters
streamThe stream.
objThe object to serialize.

◆ SerializeEventData()

byte [] Photon.SocketServer.IRpcProtocol.SerializeEventData ( EventData  eventData,
CustomTypeCache  privateCustomTypeCache = null 
)

Serializes an EventData.

Parameters
eventDataThe event data.
Returns
The serialized event.

◆ SerializeEventDataEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeEventDataEncrypted ( IEventData  eventData,
ICryptoProvider  cryptoProvider,
CustomTypeCache  privateCustomTypeCache = null 
)

Encrypts an EventData.

Parameters
eventDataThe event data.
cryptoProviderThe crypto provider.
privateCustomTypeCache
Returns
The serialized event.

◆ SerializeInitRequest()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInitRequest ( string  appName,
Version  version,
ushort  sdkId,
bool  usingIPv6 
)

Serialize an init request.

Parameters
appNameThe app Name.
versionThe version.
Returns
The serialized init response.

◆ SerializeInitRequestV2()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInitRequestV2 ( string  appName,
string  serverAddress,
Version  version,
object  custom 
)

◆ SerializeInitResponse()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInitResponse ( object  responseObject)

Serialize an init response.

Returns
The serialized init response.

◆ SerializeInternalOperationRequest()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInternalOperationRequest ( OperationRequest  operationRequest)

Serializes an internal OperationRequest.

Parameters
operationRequestThe operation request.
Returns
The serialized operation request.

◆ SerializeInternalOperationResponse()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInternalOperationResponse ( OperationResponse  operationResponse)

Serialize an OperationResponse for system operations.

Parameters
operationResponseThe operation response.
Returns
The serialized operation response.

◆ SerializeMessage()

byte [] Photon.SocketServer.IRpcProtocol.SerializeMessage ( object  message,
CustomTypeCache  privateCustomTypeCache = null 
)

◆ SerializeMessageEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeMessageEncrypted ( object  message,
ICryptoProvider  cryptoProvider,
CustomTypeCache  privateCustomTypeCache = null 
)

◆ SerializeOperationRequest()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationRequest ( OperationRequest  operationRequest,
CustomTypeCache  privateCustomTypeCache = null 
)

Serializes an OperationRequest

Parameters
operationRequestThe operation request.
Returns
A byte array containing the serialized operation request.

◆ SerializeOperationRequestEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationRequestEncrypted ( OperationRequest  operationRequest,
ICryptoProvider  cryptoProvider,
CustomTypeCache  privateCustomTypeCache = null 
)

Serializes an OperationRequest The operation request data will be encrypted using the specified ICryptoProvider.

Parameters
operationRequestThe operation request.
cryptoProviderAn ICryptoProvider instance used to encrypt the operation request.
Returns
A byte array containing the serialized operation request.

◆ SerializeOperationResponse()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationResponse ( OperationResponse  operationResponse,
CustomTypeCache  privateCustomTypeCache = null 
)

Serializes an OperationResponse.

Parameters
operationResponseThe response.
privateCustomTypeCache
Returns
The serialized operation response.

◆ SerializeOperationResponseEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationResponseEncrypted ( OperationResponse  operationResponse,
ICryptoProvider  cryptoProvider,
CustomTypeCache  privateCustomTypeCache = null 
)

Serializes an OperationResponse. The operation response data will be encrypted using the specified ICryptoProvider.

Parameters
operationResponseThe response.
cryptoProviderAn ICryptoProvider instance used to encrypt the operation response.
privateCustomTypeCache
Returns
The serialized operation response.

◆ SerializeRawMessage()

byte [] Photon.SocketServer.IRpcProtocol.SerializeRawMessage ( byte[]  message,
CustomTypeCache  privateCustomTypeCache = null 
)

◆ SerializeRawMessageEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeRawMessageEncrypted ( byte[]  message,
ICryptoProvider  cryptoProvider,
CustomTypeCache  privateCustomTypeCache = null 
)

◆ TryConvertParameter()

bool Photon.SocketServer.IRpcProtocol.TryConvertParameter ( ObjectMemberInfo< DataMemberAttribute parameterInfo,
ref object  value 
)

Since C# supports many more types than the used protocol some parameters need to be converted. This method tries to convert an operation request parameter into to a type that works for a target field or property.

Parameters
parameterInfoThe parameter info.
valueThe value.
Returns
True if value has a valid type.

◆ TryParse() [1/2]

bool Photon.SocketServer.IRpcProtocol.TryParse ( byte[]  data,
int  startIndex,
int  length,
out object  value,
CustomTypeCache  privateCustomTypeCache = null 
)

Try to parse an object from a byte array.

Parameters
dataAn array of bytes.
startIndexThe starting position within data.
lengthThe number of array elements in data to parse.
valueThe result object.
privateCustomTypeCache
Returns
True on success; otherwise false.

◆ TryParse() [2/2]

bool Photon.SocketServer.IRpcProtocol.TryParse ( Stream  stream,
out object  obj,
CustomTypeCache  privateCustomTypeCache = null 
)

Try to parse an object from a stream.

Parameters
streamThe stream.
objThe result object.
Returns
True on success.

◆ TryParseEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
int  startIndex,
int  length,
out object  value,
CustomTypeCache  privateCustomTypeCache = null 
)

◆ TryParseEventData()

bool Photon.SocketServer.IRpcProtocol.TryParseEventData ( byte[]  data,
out EventData  eventData,
CustomTypeCache  privateCustomTypeCache = null 
)

Tries to convert a byte array into an EventData instance. The data was serialized with IRpcProtocol.SerializeEventData.

Parameters
dataThe data.
eventDataThe event data.
privateCustomTypeCache
Returns
True on success.

◆ TryParseEventDataEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseEventDataEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out EventData  eventData,
CustomTypeCache  privateCustomTypeCache = null 
)

Tries to convert a byte array into an EventData instance. The data was serialized with IRpcProtocol.SerializeEventDataEncrypted.

Parameters
dataThe data.
cryptoProviderThe crypto provider.
eventDataThe event data.
privateCustomTypeCache
Returns
True on success.

◆ TryParseMessageHeader()

bool Photon.SocketServer.IRpcProtocol.TryParseMessageHeader ( byte[]  data,
out RtsMessageHeader  header 
)

Tries to parse the header.

Parameters
dataThe data.
headerThe header.
Returns
True on success.

◆ TryParseOperationRequest()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationRequest ( byte[]  data,
out OperationRequest  operationRequest,
CustomTypeCache  privateCustomTypeCache = null 
)

Tries to convert a byte array into an OperationRequest instance. The data was serialized with IRpcProtocol.SerializeOperationRequest.

Parameters
dataThe data.
operationRequestThe operation Request.
privateCustomTypeCache
Returns
True on success.

◆ TryParseOperationRequestEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationRequestEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out OperationRequest  operationRequest,
CustomTypeCache  privateCustomTypeCache 
)

Tries to convert a byte array into an OperationRequest instance. The data was serialized with IRpcProtocol.SerializeOperationRequestEncrypted.

Parameters
dataThe data.
cryptoProviderThe crypto Provider.
operationRequestThe operation Request.
privateCustomTypeCache
Returns
True on success.

◆ TryParseOperationResponse()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationResponse ( byte[]  data,
out OperationResponse  operationResponse,
CustomTypeCache  privateCustomTypeCache = null 
)

Tries to convert a byte array into an OperationResponse instance. The data was serialized with IRpcProtocol.SerializeOperationResponse.

Parameters
dataThe data.
operationResponseThe operation Response.
privateCustomTypeCache
Returns
True on success.

◆ TryParseOperationResponseEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationResponseEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out OperationResponse  operationResponse,
CustomTypeCache  privateCustomTypeCache = null 
)

Tries to convert a byte array into an OperationResponse instance. The data was serialized with IRpcProtocol.SerializeOperationResponseEncrypted.

Parameters
dataThe data.
cryptoProviderThe crypto Provider.
operationResponseThe operation Response.
privateCustomTypeCache
Returns
True on success.

Property Documentation

◆ HeaderSize

int Photon.SocketServer.IRpcProtocol.HeaderSize
get

Gets the size used for the protocol header.

◆ MessageContentType

MessageContentType Photon.SocketServer.IRpcProtocol.MessageContentType
get

◆ ProtocolType

ProtocolType Photon.SocketServer.IRpcProtocol.ProtocolType
get

Gets the type of the protocol.

The type of the protocol.