3rd Eye Scene C#
3rd Eye Scene C# documentation
|
A utility class for encoding CollatedPacketMessage packets, including compression. More...
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. |
A utility class for encoding CollatedPacketMessage packets, including compression.
Typical usage:
See CollatedPacketDecoder for notes on why
System.IO.Compression
is not used.
Derives the IConnection interface for compatibility.
Tes::Util::CollatedPacketEncoder::CollatedPacketEncoder | ( | bool | compress, |
int | initialBufferSize = 64 * 1024 |
||
) | [inline] |
Create an encoder with the target initial buffer size.
compress | True to compress collated data. |
initialBufferSize | The initial buffer size (bytes). |
int Tes::Util::CollatedPacketEncoder::Add | ( | PacketBuffer | packet | ) | [inline] |
Add the given packet.
packet | The buffer to collate. |
int Tes::Util::CollatedPacketEncoder::Add | ( | byte[] | bytes, |
int | offset, | ||
int | length | ||
) | [inline] |
Add bytes from the given buffer.
bytes | Buffer to add from. |
offset | Offset to the first byte in bytes to add. |
length | Number of bytes from buffer to add. |
uint Tes::Util::CollatedPacketEncoder::AddResource | ( | Resource | resource | ) | [inline] |
Not supported for packet collation.
Throws NotSupportedException.
resource |
Implements Tes::Net::IConnection.
int Tes::Util::CollatedPacketEncoder::Create | ( | Shape | shape | ) | [inline] |
int Tes::Util::CollatedPacketEncoder::Destroy | ( | Shape | shape | ) | [inline] |
bool Tes::Util::CollatedPacketEncoder::FinaliseEncoding | ( | ) | [inline] |
Finalise the collated packet before sending.
uint Tes::Util::CollatedPacketEncoder::GetReferenceCount | ( | Resource | resource | ) | [inline] |
Not supported for packet collation.
resource |
Implements Tes::Net::IConnection.
uint Tes::Util::CollatedPacketEncoder::RemoveResource | ( | Resource | resource | ) | [inline] |
Not supported for packet collation.
Throws NotSupportedException.
resource |
Implements Tes::Net::IConnection.
int Tes::Util::CollatedPacketEncoder::Send | ( | byte[] | bytes, |
int | offset, | ||
int | length | ||
) | [inline] |
Sends data on the client connection.
Aliases Add(byte[], int, int).
bytes | The data buffer to send. |
offset | An offset into bytes at which to start sending. |
length | The number of bytes to transfer. |
Implements Tes::Net::IConnection.
bool Tes::Util::CollatedPacketEncoder::SendServerInfo | ( | ServerInfoMessage | info | ) | [inline] |
Sends the ServerInfoMessage structure to the connected client.
info | The info message to send. |
Implements Tes::Net::IConnection.
void Tes::Util::CollatedPacketEncoder::SetPayloadSize | ( | ushort | size | ) | [inline, protected] |
Sets the PacketHeader.PayloadSize value.
size | The packet payload size (compressed). |
void Tes::Util::CollatedPacketEncoder::SetUncompressedBytesSize | ( | uint | size | ) | [inline, protected] |
Sets the CollatedPacketMessage.UncompressedBytes value.
size | The number of uncompressed in the payload. |
int Tes::Util::CollatedPacketEncoder::Update | ( | Shape | shape | ) | [inline] |
int Tes::Util::CollatedPacketEncoder::UpdateFrame | ( | float | dt, |
bool | flush | ||
) | [inline] |
void Tes::Util::CollatedPacketEncoder::WriteHeaderData | ( | int | dstOffset, |
byte[] | bytes | ||
) | [inline, protected] |
Write data into the header section at the given offset.
dstOffset | Buffer offset to write at. |
bytes | Bytes to write. |
byte [] Tes::Util::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::Util::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.