3rd Eye Scene C#
3rd Eye Scene C# documentation
Tes::IO::CollatedPacketEncoder Class Reference

A utility class for encoding CollatedPacketMessage packets, including compression. More...

Inheritance diagram for Tes::IO::CollatedPacketEncoder:
Tes::Net::IConnection

List of all members.

Public Member Functions

 CollatedPacketEncoder (bool compress, int initialBufferSize=64 *1024)
 Create an encoder with the target initial buffer size.
void Reset ()
 Reset the buffer to start again.
int Add (PacketBuffer packet)
 Add the given packet.
int Add (byte[] bytes, int offset, int length)
 Add bytes from the given buffer.
bool FinaliseEncoding ()
 Finalise the collated packet before sending.
void Close ()
 Ignored.
int UpdateFrame (float dt, bool flush)
 Not supported.
int Create (Shape shape)
 Send the create message for shape .
int Destroy (Shape shape)
 Send the create message for shape .
int Update (Shape shape)
 Send the create message for shape .
bool SendServerInfo (ServerInfoMessage info)
 Sends the ServerInfoMessage structure to the connected client.
int Send (byte[] bytes, int offset, int length)
 Sends data on the client connection.
uint GetReferenceCount (Resource resource)
 Not supported for packet collation.
uint AddResource (Resource resource)
 Not supported for packet collation.
uint RemoveResource (Resource resource)
 Not supported for packet collation.

Protected Member Functions

void SetPayloadSize (ushort size)
 Sets the PacketHeader.PayloadSize value.
void SetUncompressedBytesSize (uint size)
 Sets the CollatedPacketMessage.UncompressedBytes value.
void WriteHeaderData (int dstOffset, byte[] bytes)
 Write data into the header section at the given offset.

Properties

static int Overhead [get]
 Byte count overhead added by using a collated packet.
static ushort MaxPacketSize [get]
 The default packet size limit for a CollatedPacketMessage.
bool CompressionEnabled [get, set]
 True if created with compression.
byte[] Buffer [get]
 Direct access to the internal buffer bytes.
int Count [get]
 The total number of bytes written to Buffer.
int CollatedBytes [get, set]
 The number of bytes written to Buffer excluding the Overhead.
string Address [get]
 Identifies as "CollatedPacket".
int Port [get]
 Always zero.
bool Connected [get]
 Always true.

Detailed Description

A utility class for encoding CollatedPacketMessage packets, including compression.

Typical usage:

  • Instantiate the packet encoder.
  • Reset the encoder.
  • For each constituent message:
  • Call FinaliseEncoding() on the encoder
  • Send the encoded packet.
  • Reset the encoder.

See CollatedPacketDecoder for notes on why

System.IO.Compression

is not used.

Derives the IConnection interface for compatibility.


Constructor & Destructor Documentation

Tes::IO::CollatedPacketEncoder::CollatedPacketEncoder ( bool  compress,
int  initialBufferSize = 64 * 1024 
) [inline]

Create an encoder with the target initial buffer size.

Parameters:
compressTrue to compress collated data.
initialBufferSizeThe initial buffer size (bytes).

Member Function Documentation

int Tes::IO::CollatedPacketEncoder::Add ( PacketBuffer  packet) [inline]

Add the given packet.

Parameters:
packetThe buffer to collate.
Returns:
The number of (uncompressed) bytes added.
int Tes::IO::CollatedPacketEncoder::Add ( byte[]  bytes,
int  offset,
int  length 
) [inline]

Add bytes from the given buffer.

Parameters:
bytesBuffer to add from.
offsetOffset to the first byte in bytes to add.
lengthNumber of bytes from buffer to add.
Returns:
The number of (uncompressed) bytes added.
uint Tes::IO::CollatedPacketEncoder::AddResource ( Resource  resource) [inline]

Not supported for packet collation.

Throws NotSupportedException.

Parameters:
resource

Implements Tes::Net::IConnection.

int Tes::IO::CollatedPacketEncoder::Create ( Shape  shape) [inline]

Send the create message for shape .

Parameters:
shape
Returns:

Implements Tes::Net::IConnection.

int Tes::IO::CollatedPacketEncoder::Destroy ( Shape  shape) [inline]

Send the create message for shape .

Parameters:
shape
Returns:

Implements Tes::Net::IConnection.

bool Tes::IO::CollatedPacketEncoder::FinaliseEncoding ( ) [inline]

Finalise the collated packet before sending.

Returns:
True on successful finalisation, false if already finalised
uint Tes::IO::CollatedPacketEncoder::GetReferenceCount ( Resource  resource) [inline]

Not supported for packet collation.

Parameters:
resource
Returns:
0

Implements Tes::Net::IConnection.

uint Tes::IO::CollatedPacketEncoder::RemoveResource ( Resource  resource) [inline]

Not supported for packet collation.

Throws NotSupportedException.

Parameters:
resource

Implements Tes::Net::IConnection.

int Tes::IO::CollatedPacketEncoder::Send ( byte[]  bytes,
int  offset,
int  length 
) [inline]

Sends data on the client connection.

Aliases Add(byte[], int, int).

Parameters:
bytesThe data buffer to send.
offsetAn offset into bytes at which to start sending.
lengthThe number of bytes to transfer.
Returns:
The number of bytes transferred or -1 on failure.

Implements Tes::Net::IConnection.

bool Tes::IO::CollatedPacketEncoder::SendServerInfo ( ServerInfoMessage  info) [inline]

Sends the ServerInfoMessage structure to the connected client.

Parameters:
infoThe info message to send.
Returns:
True on success.

Implements Tes::Net::IConnection.

void Tes::IO::CollatedPacketEncoder::SetPayloadSize ( ushort  size) [inline, protected]

Sets the PacketHeader.PayloadSize value.

Parameters:
sizeThe packet payload size (compressed).
void Tes::IO::CollatedPacketEncoder::SetUncompressedBytesSize ( uint  size) [inline, protected]

Sets the CollatedPacketMessage.UncompressedBytes value.

Parameters:
sizeThe number of uncompressed in the payload.
int Tes::IO::CollatedPacketEncoder::Update ( Shape  shape) [inline]

Send the create message for shape .

Parameters:
shape
Returns:

Implements Tes::Net::IConnection.

int Tes::IO::CollatedPacketEncoder::UpdateFrame ( float  dt,
bool  flush 
) [inline]

Not supported.

Parameters:
dt
flush
Returns:

Implements Tes::Net::IConnection.

void Tes::IO::CollatedPacketEncoder::WriteHeaderData ( int  dstOffset,
byte[]  bytes 
) [inline, protected]

Write data into the header section at the given offset.

Parameters:
dstOffsetBuffer offset to write at.
bytesBytes to write.

Property Documentation

byte [] Tes::IO::CollatedPacketEncoder::Buffer [get]

Direct access to the internal buffer bytes.

Intended to aid in serialisation of completed packets. For example:

          writer.Send(packet.Buffer, 0, packet.Count)

Use with care.

int Tes::IO::CollatedPacketEncoder::Overhead [static, get]

Byte count overhead added by using a collated packet.

This is the sum of PacketHeader, CollatedPacketMessage and the Crc16 value type.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Properties Events