C# Класс NetworkCommsDotNet.Tools.PacketBuilder

Packet data is generally broken into multiple variable sized byte chunks or 'partial packets'. This class provides features to effortlessly rebuild whole packets.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddPartialPacket ( int packetBytes, byte partialPacket ) : void

Add a partial packet to the end of the cache by reference.

ClearNTopBytes ( int numBytesToRemove ) : void

Clear N bytes from cache, starting with oldest bytes first.

FirstByte ( ) : byte

Returns the value of the first cached byte.

GetAllData ( ) : byte[]

Copies all cached bytes into a single array and returns. Original data is left unchanged.

NumUnusedBytesMostRecentPartialPacket ( ) : int

Returns the number of unused bytes in the most recently cached partial packet.

PacketBuilder ( ) : System

Create a new instance of the ConnectionPacketBuilder class

ReadDataSection ( int startIndex, int length ) : MemoryStream

Copies the requested cached bytes into a single array and returns. Original data is left unchanged.

RemoveMostRecentPartialPacket ( int &lastPacketBytesRead ) : byte[]

Returns the most recently cached partial packet and removes it from the cache. Used to more efficiently utilise allocated memory space.

Описание методов

AddPartialPacket() публичный Метод

Add a partial packet to the end of the cache by reference.
public AddPartialPacket ( int packetBytes, byte partialPacket ) : void
packetBytes int The number of valid bytes in the provided partial packet
partialPacket byte A buffer which may or may not be full with valid bytes
Результат void

ClearNTopBytes() публичный Метод

Clear N bytes from cache, starting with oldest bytes first.
public ClearNTopBytes ( int numBytesToRemove ) : void
numBytesToRemove int The total number of bytes to be removed.
Результат void

FirstByte() публичный Метод

Returns the value of the first cached byte.
public FirstByte ( ) : byte
Результат byte

GetAllData() публичный Метод

Copies all cached bytes into a single array and returns. Original data is left unchanged.
public GetAllData ( ) : byte[]
Результат byte[]

NumUnusedBytesMostRecentPartialPacket() публичный Метод

Returns the number of unused bytes in the most recently cached partial packet.
public NumUnusedBytesMostRecentPartialPacket ( ) : int
Результат int

PacketBuilder() публичный Метод

Create a new instance of the ConnectionPacketBuilder class
public PacketBuilder ( ) : System
Результат System

ReadDataSection() публичный Метод

Copies the requested cached bytes into a single array and returns. Original data is left unchanged.
public ReadDataSection ( int startIndex, int length ) : MemoryStream
startIndex int The inclusive byte index to use as the starting position.
length int The total number of desired bytes.
Результат System.IO.MemoryStream

RemoveMostRecentPartialPacket() публичный Метод

Returns the most recently cached partial packet and removes it from the cache. Used to more efficiently utilise allocated memory space.
public RemoveMostRecentPartialPacket ( int &lastPacketBytesRead ) : byte[]
lastPacketBytesRead int The number of valid bytes in the last partial packet added
Результат byte[]