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

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.
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.
Photon.SocketServer.EventData.EventData ( byte  eventCode)
inline

Initializes a new instance of the EventData class.

Parameters
eventCodeThe event code.
Photon.SocketServer.EventData.EventData ( )
inline

Initializes a new instance of the EventData class.

Member Function Documentation

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

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.
void Photon.SocketServer.EventData.SetParameters ( Dictionary< byte, object >  parameters)
inline

Replaces the Parameters with parameters .

Parameters
parametersThe parameters to set.

Property Documentation

byte Photon.SocketServer.EventData.Code
getset

Gets or sets the event code.

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

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

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.