Photon Quantum 3.0.0

Public Member Functions | Public Attributes | List of all members
Photon.Deterministic.DeterministicCommandSerializer Class Reference

The DeterministicCommandSerializer is used to serialize and de-serialize DeterministicCommands. More...

Public Member Functions

 DeterministicCommandSerializer ()
 Constructor. More...
 
bool EncodeCommand (DeterministicCommand command, out byte[] result)
 Encodes the command into a byte array. Creates a new byte array and returns it. Reusing byte arrays is not recommended because of the uncertain resulting size. More...
 
Boolean PackNext (BitStream s, DeterministicCommand cmd)
 Packing a command into a bitstream. More...
 
Boolean ReadNext (BitStream s, out DeterministicCommand cmd)
 Read commands from the bitstream. More...
 
void RegisterFactories (params IDeterministicCommandFactory[] factories)
 Register a list of command factories. More...
 
void RegisterFactory (IDeterministicCommandFactory factory)
 Register one command factory. More...
 
bool TryDecodeCommand< T > (byte[] data, out T result)
 Decodes command message byte array into a specific command type. More...
 

Public Attributes

BitStream CommandSerializerStreamRead
 The reusable read stream. Use BitStream.SetBuffer(byte[]) before using. More...
 
BitStream CommandSerializerStreamWrite
 The re-useable write stream. Use BitStream.Reset(int) before using. More...
 

Detailed Description

The DeterministicCommandSerializer is used to serialize and de-serialize DeterministicCommands.

Constructor & Destructor Documentation

◆ DeterministicCommandSerializer()

Photon.Deterministic.DeterministicCommandSerializer.DeterministicCommandSerializer ( )
inline

Constructor.

Member Function Documentation

◆ RegisterFactory()

void Photon.Deterministic.DeterministicCommandSerializer.RegisterFactory ( IDeterministicCommandFactory  factory)
inline

Register one command factory.

Parameters
factoryFactory instance

◆ RegisterFactories()

void Photon.Deterministic.DeterministicCommandSerializer.RegisterFactories ( params IDeterministicCommandFactory[]  factories)
inline

Register a list of command factories.

Parameters
factoriesFactory params

◆ TryDecodeCommand< T >()

bool Photon.Deterministic.DeterministicCommandSerializer.TryDecodeCommand< T > ( byte[]  data,
out T  result 
)
inline

Decodes command message byte array into a specific command type.

Template Parameters
TCommand type to cast to
Parameters
dataSerialized command data.
resultResulting command instance.
Returns
Returns true when successfully decoded and casted.
Type Constraints
T :DeterministicCommand 

◆ EncodeCommand()

bool Photon.Deterministic.DeterministicCommandSerializer.EncodeCommand ( DeterministicCommand  command,
out byte[]  result 
)
inline

Encodes the command into a byte array. Creates a new byte array and returns it. Reusing byte arrays is not recommended because of the uncertain resulting size.

Parameters
commandCommand instance
resultSerialized command to be send to the clients for example.
Returns
Returns true when successfully encoded.

◆ PackNext()

Boolean Photon.Deterministic.DeterministicCommandSerializer.PackNext ( BitStream  s,
DeterministicCommand  cmd 
)
inline

Packing a command into a bitstream.

Parameters
sStream
cmdCommand object
Returns
true if successfully written the command into the stream

◆ ReadNext()

Boolean Photon.Deterministic.DeterministicCommandSerializer.ReadNext ( BitStream  s,
out DeterministicCommand  cmd 
)
inline

Read commands from the bitstream.

Parameters
sStream
cmdCommand that was read from the stream.
Returns
true when a command has successfully been read form the stream.

Member Data Documentation

◆ CommandSerializerStreamRead

BitStream Photon.Deterministic.DeterministicCommandSerializer.CommandSerializerStreamRead

The reusable read stream. Use BitStream.SetBuffer(byte[]) before using.

◆ CommandSerializerStreamWrite

BitStream Photon.Deterministic.DeterministicCommandSerializer.CommandSerializerStreamWrite

The re-useable write stream. Use BitStream.Reset(int) before using.