Photon Server API

Public Member Functions | Static Public Member Functions | Properties | List of all members
Photon.SocketServer.EventData Class Reference

This class contains data that is sent to clients with PhotonPeer.SendEvent. The IRpcProtocol serializes EventData with SerializeEventData. SetParameters(object) converts properties that are flagged with DataMemberAttribute into the Parameters dictionary. More...

Inheritance diagram for Photon.SocketServer.EventData:
Photon.SocketServer.IEventData

Public Member Functions

 EventData (byte eventCode, object dataContract)
 Initializes a new instance of the EventData class. More...
 
 EventData (byte eventCode, Dictionary< byte, object > parameters)
 Initializes a new instance of the EventData class. This constructor sets the Parameters and the Code. More...
 
 EventData (byte eventCode)
 Initializes a new instance of the EventData class. More...
 
 EventData ()
 Initializes a new instance of the EventData class. More...
 
void SendTo< TPeer > (IEnumerable< TPeer > peers, SendParameters sendParameters)
 Sends the event to a list of peers. This method serializes the data just once per protocol instead of once per peer. More...
 
void SetParameters (object dataContract)
 Converts properties of an object to Parameters. Included properties require the DataMemberAttribute. More...
 
void SetParameters (Dictionary< byte, object > parameters)
 Replaces the Parameters with parameters . More...
 
byte[] Serialize (IRpcProtocol protocol, CustomTypeCache privateCustomTypeCache)
 Serializes this instance with the protocol . More...
 

Static Public Member Functions

static void SendTo< TPeer > (IEventData eventData, IEnumerable< TPeer > peers, SendParameters sendParameters)
 Sends an event to a list of peers. This method serializes the data just once per protocol instead of once per peer. More...
 

Properties

byte Code [get, set]
 Gets or sets the event code. More...
 
Dictionary< byte, object > Parameters [get, set]
 Gets or sets the event parameters that will be sent to the client. More...
 
object this[byte parameterKey] [get, set]
 Gets or sets the paramter associated with the specified key. More...
 
- Properties inherited from Photon.SocketServer.IEventData
byte Code [get]
 Gets Code. More...
 
object this[byte parameterKey] [get, set]
 Gets or sets the paramter associated with the specified key. More...
 
Dictionary< byte, object > Parameters [get]
 Gets the event parameters that will be sent to the client. More...
 

Detailed Description

This class contains data that is sent to clients with PhotonPeer.SendEvent. The IRpcProtocol serializes EventData with SerializeEventData. SetParameters(object) converts properties that are flagged with DataMemberAttribute into the Parameters dictionary.

Constructor & Destructor Documentation

◆ EventData() [1/4]

Photon.SocketServer.EventData.EventData ( byte  eventCode,
object  dataContract 
)
inline

Initializes a new instance of the EventData class.

Parameters
eventCodeThe event Code.
dataContractAll properties of dataContract with the DataMemberAttribute are mapped to the Parameters dictionary.

◆ EventData() [2/4]

Photon.SocketServer.EventData.EventData ( byte  eventCode,
Dictionary< byte, object >  parameters 
)
inline

Initializes a new instance of the EventData class. This constructor sets the Parameters and the Code.

Parameters
eventCodeDetermines the Code.
parametersDetermines the Parameters.

◆ EventData() [3/4]

Photon.SocketServer.EventData.EventData ( byte  eventCode)
inline

Initializes a new instance of the EventData class.

Parameters
eventCodeThe event code.

◆ EventData() [4/4]

Photon.SocketServer.EventData.EventData ( )
inline

Initializes a new instance of the EventData class.

Member Function Documentation

◆ SendTo< TPeer >() [1/2]

void Photon.SocketServer.EventData.SendTo< TPeer > ( IEnumerable< TPeer >  peers,
SendParameters  sendParameters 
)
inline

Sends the event to a list of peers. This method serializes the data just once per protocol instead of once per peer.

Parameters
peersThe peers to send the event to.
sendParametersThe send Options.
Template Parameters
TPeerA PeerBase subclass type.
Type Constraints
TPeer :PeerBase 

◆ SendTo< TPeer >() [2/2]

static void Photon.SocketServer.EventData.SendTo< TPeer > ( IEventData  eventData,
IEnumerable< TPeer >  peers,
SendParameters  sendParameters 
)
inlinestatic

Sends an event to a list of peers. This method serializes the data just once per protocol instead of once per peer.

Parameters
eventDataThe event to send.
peersThe peers to send the event to.
sendParametersThe send Options.
Template Parameters
TPeerA PeerBase subclass type.
Type Constraints
TPeer :PeerBase 

◆ Serialize()

byte [] Photon.SocketServer.EventData.Serialize ( IRpcProtocol  protocol,
CustomTypeCache  privateCustomTypeCache 
)
inline

Serializes this instance with the protocol .

Parameters
protocolThe protocol.
privateCustomTypeCache
Returns
A byte array.

Implements Photon.SocketServer.IEventData.

◆ SetParameters() [1/2]

void Photon.SocketServer.EventData.SetParameters ( Dictionary< byte, object >  parameters)
inline

Replaces the Parameters with parameters .

Parameters
parametersThe parameters to set.

◆ SetParameters() [2/2]

void Photon.SocketServer.EventData.SetParameters ( object  dataContract)
inline

Converts properties of an object to Parameters. Included properties require the DataMemberAttribute.

Parameters
dataContractThe properties of this object are mapped to Parameters.

Property Documentation

◆ Code

byte Photon.SocketServer.EventData.Code
getset

Gets or sets the event code.

◆ Parameters

Dictionary<byte, object> Photon.SocketServer.EventData.Parameters
getset

Gets or sets the event parameters that will be sent to the client.

◆ this[byte parameterKey]

object Photon.SocketServer.EventData.this[byte parameterKey]
getset

Gets or sets the paramter associated with the specified key.

Parameters
parameterKeyThe key of the parameter to get or set.
Returns
The parameter associated with the specified key. If the specified key is not found, a get operation throws a KeyNotFoundException, and a set operation creates a new paramter with the specified key.
Exceptions
System.NullReferenceExceptionThe Parameters property has not been initialized.