Photon Server API Documentation v5.0RC1

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.GpBinaryByte.GpBinaryByteProtocolV16, Photon.SocketServer.Rpc.Protocols.GpBinaryV17.GpBinaryProtocolV17, Photon.SocketServer.Rpc.Protocols.GpBinaryV18.GpBinaryProtocolV18, and Photon.SocketServer.Rpc.Protocols.Json.JsonProtocol.

Public Member Functions

void Serialize (Stream stream, object obj, SerializeSetup peerSetup=new SerializeSetup())
 Serialize an object to a stream More...
 
byte[] SerializeEventData (EventData eventData, SerializeSetup peerSetup=new SerializeSetup())
 Serializes an EventData. More...
 
byte[] SerializeEventDataEncrypted (IEventData eventData, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 Encrypts an EventData. More...
 
byte[] SerializeInitRequest (string appName, Version version, byte sdkId, bool usingIPv6)
 Serialize an init request. More...
 
byte[] SerializeInitRequestV2 (string appName, string serverAddress, Version version, ushort sdkId, object custom)
 
byte[] SerializeInitRequestV3 (string appName, Version version, ushort sdkId, byte platformId, bool usingIPv6, object custom, byte[] token, EncryptionData encryptionData, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeInitResponse (object responseObject)
 Serialize an init response. More...
 
byte[] SerializeInitV3Response (InitV3Response response, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeMessage (object message, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeMessageEncrypted (object message, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeRawMessage (byte[] message, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeRawMessageEncrypted (byte[] message, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeInternalOperationRequest (OperationRequest operationRequest)
 Serializes an internal OperationRequest. More...
 
byte[] SerializeInternalOperationResponse (OperationResponse operationResponse)
 Serialize an OperationResponse for system operations. More...
 
byte[] SerializeOperationRequest (OperationRequest operationRequest, SerializeSetup peerSetup=new SerializeSetup())
 Serializes an OperationRequest More...
 
byte[] SerializeOperationRequestEncrypted (OperationRequest operationRequest, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 Serializes an OperationRequest The operation request data will be encrypted using the specified ICryptoProvider. More...
 
byte[] SerializeOperationResponse (OperationResponse operationResponse, SerializeSetup peerSetup=new SerializeSetup())
 Serializes an OperationResponse. More...
 
byte[] SerializeOperationResponseEncrypted (OperationResponse operationResponse, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 Serializes an OperationResponse. The operation response data will be encrypted using the specified ICryptoProvider. More...
 
byte[] SerializeDisconnectMessageEncrypted (DisconnectMessage message, ICryptoProvider cryptoProvider, SerializeSetup peerSetup=new SerializeSetup())
 
byte[] SerializeDisconnectMessage (DisconnectMessage message, SerializeSetup peerSetup=new SerializeSetup())
 
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, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 Try to parse an object from a stream. More...
 
bool TryParse (byte[] data, int startIndex, int length, out object value, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 Try to parse an object from a byte array. More...
 
bool TryParseEncrypted (byte[] data, ICryptoProvider cryptoProvider, int startIndex, int length, out object value, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 
bool TryParseEventData (byte[] data, out EventData eventData, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 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, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 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, out short errorCode, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 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, out short errorCode, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 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, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 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, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 Tries to convert a byte array into an OperationResponse instance. The data was serialized with IRpcProtocol.SerializeOperationResponseEncrypted. More...
 
bool TryParseDisconnectMessageEncrypted (byte[] data, ICryptoProvider cryptoProvider, out DisconnectMessage message, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 
bool TryParseDisconnectMessage (byte[] data, out DisconnectMessage message, out string errorMsg, SerializeSetup peerSetup=new SerializeSetup())
 

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,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Serialize an object to a stream

Parameters
streamThe stream.
objThe object to serialize.
peerSetup

◆ SerializeDisconnectMessage()

byte [] Photon.SocketServer.IRpcProtocol.SerializeDisconnectMessage ( DisconnectMessage  message,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeDisconnectMessageEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeDisconnectMessageEncrypted ( DisconnectMessage  message,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeEventData()

byte [] Photon.SocketServer.IRpcProtocol.SerializeEventData ( EventData  eventData,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Serializes an EventData.

Parameters
eventDataThe event data.
peerSetup
Returns
The serialized event.

◆ SerializeEventDataEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeEventDataEncrypted ( IEventData  eventData,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Encrypts an EventData.

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

◆ SerializeInitRequest()

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

Serialize an init request.

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

◆ SerializeInitRequestV2()

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

◆ SerializeInitRequestV3()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInitRequestV3 ( string  appName,
Version  version,
ushort  sdkId,
byte  platformId,
bool  usingIPv6,
object  custom,
byte[]  token,
EncryptionData  encryptionData,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeInitResponse()

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

Serialize an init response.

Returns
The serialized init response.

◆ SerializeInitV3Response()

byte [] Photon.SocketServer.IRpcProtocol.SerializeInitV3Response ( InitV3Response  response,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ 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,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeMessageEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeMessageEncrypted ( object  message,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeOperationRequest()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationRequest ( OperationRequest  operationRequest,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Serializes an OperationRequest

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

◆ SerializeOperationRequestEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationRequestEncrypted ( OperationRequest  operationRequest,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
peerSetup
Returns
A byte array containing the serialized operation request.

◆ SerializeOperationResponse()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationResponse ( OperationResponse  operationResponse,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Serializes an OperationResponse.

Parameters
operationResponseThe response.
peerSetup
Returns
The serialized operation response.

◆ SerializeOperationResponseEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeOperationResponseEncrypted ( OperationResponse  operationResponse,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
peerSetup
Returns
The serialized operation response.

◆ SerializeRawMessage()

byte [] Photon.SocketServer.IRpcProtocol.SerializeRawMessage ( byte[]  message,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ SerializeRawMessageEncrypted()

byte [] Photon.SocketServer.IRpcProtocol.SerializeRawMessageEncrypted ( byte[]  message,
ICryptoProvider  cryptoProvider,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ 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,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
errorMsg
peerSetup
Returns
True on success; otherwise false.

◆ TryParse() [2/2]

bool Photon.SocketServer.IRpcProtocol.TryParse ( Stream  stream,
out object  obj,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

Try to parse an object from a stream.

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

◆ TryParseDisconnectMessage()

bool Photon.SocketServer.IRpcProtocol.TryParseDisconnectMessage ( byte[]  data,
out DisconnectMessage  message,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ TryParseDisconnectMessageEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseDisconnectMessageEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out DisconnectMessage  message,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ TryParseEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
int  startIndex,
int  length,
out object  value,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

◆ TryParseEventData()

bool Photon.SocketServer.IRpcProtocol.TryParseEventData ( byte[]  data,
out EventData  eventData,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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

Parameters
dataThe data.
eventDataThe event data.
errorMsg
peerSetup
Returns
True on success.

◆ TryParseEventDataEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseEventDataEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out EventData  eventData,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
errorMsg
peerSetup
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,
out short  errorCode,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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

Parameters
dataThe data.
operationRequestThe operation Request.
errorCode
errorMsg
peerSetup
Returns
True on success.

◆ TryParseOperationRequestEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationRequestEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out OperationRequest  operationRequest,
out short  errorCode,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
errorCode
errorMsg
peerSetup
Returns
True on success.

◆ TryParseOperationResponse()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationResponse ( byte[]  data,
out OperationResponse  operationResponse,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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

Parameters
dataThe data.
operationResponseThe operation Response.
errorMsg
peerSetup
Returns
True on success.

◆ TryParseOperationResponseEncrypted()

bool Photon.SocketServer.IRpcProtocol.TryParseOperationResponseEncrypted ( byte[]  data,
ICryptoProvider  cryptoProvider,
out OperationResponse  operationResponse,
out string  errorMsg,
SerializeSetup  peerSetup = new SerializeSetup() 
)

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.
errorMsg
peerSetup
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.