Table of Contents

Struct PacketReader

Namespace
Xabbo.Messages
Assembly
Xabbo.Common.dll

Provides primitive packet read operations.

public readonly ref struct PacketReader
Inherited Members

Constructors

PacketReader(IPacket)

public PacketReader(IPacket packet)

Parameters

packet IPacket

PacketReader(IPacket, ref int, IParserContext?)

Provides primitive packet read operations.

public PacketReader(IPacket packet, ref int pos, IParserContext? context = null)

Parameters

packet IPacket
pos int
context IParserContext

Fields

Pos

public readonly ref int Pos

Field Value

int

Properties

Available

public int Available { get; }

Property Value

int

Client

public ClientType Client { get; }

Property Value

ClientType

Context

public IParserContext? Context { get; }

Property Value

IParserContext

Encoding

public Encoding Encoding { get; }

Property Value

Encoding

Header

public Header Header { get; }

Property Value

Header

Length

public int Length { get; }

Property Value

int

Span

public ReadOnlySpan<byte> Span { get; }

Property Value

ReadOnlySpan<byte>

Methods

ParseArray<T>()

Parses an array of T from the current position and advances it.

public T[] ParseArray<T>() where T : IParser<T>

Returns

T[]

Type Parameters

T

Parse<T>()

Parses a T from the current position and advances it.

public T Parse<T>() where T : IParser<T>

Returns

T

Type Parameters

T

ReadB64()

Reads a B64 from the current position and advances it.

Not supported on Unity or Flash.
public B64 ReadB64()

Returns

B64

Exceptions

UnsupportedClientException

If the Client is Unity or Flash.

ReadBool()

Reads a bool from the current position and advances it.

Decoded as a VL64 on Shockwave, otherwise as a byte .
public bool ReadBool()

Returns

bool

ReadByte()

Reads a byte from the current position and advances it.

Not supported on Shockwave.
public byte ReadByte()

Returns

byte

Exceptions

UnsupportedClientException

If the Client is Shockwave.

ReadContent()

Reads the contents of the packet as a string and advances the position to the end of the packet. The position must be at the start of the packet.

Only supported on Shockwave.
public string ReadContent()

Returns

string

ReadFloat()

Reads a float from the current position and advances it.

Read as a string on Flash and Shockwave, otherwise decoded as a 32-bit floating point number.
public float ReadFloat()

Returns

float

ReadId()

Reads an Id from the current position and advances it.

Read as a long on Unity, or an int on Flash and Shockwave.
public Id ReadId()

Returns

Id

Exceptions

UnsupportedClientException

If the client type is invalid.

ReadIdArray()

Reads an Id array from the current position and advances it.

public Id[] ReadIdArray()

Returns

Id[]

ReadInt()

Reads an int from the current position and advances it.

Decoded as a VL64 on Shockwave, otherwise as a 32-bit integer.
public int ReadInt()

Returns

int

ReadIntArray()

Reads an int array from the current position and advances it.

public int[] ReadIntArray()

Returns

int[]

ReadLength()

Reads a Length from the current position and advances it.

Read as a short on Unity, or an int on Flash and Shockwave.
public Length ReadLength()

Returns

Length

Exceptions

UnsupportedClientException

If the client type is invalid.

ReadLong()

Reads a long from the current position and advances it.

Decoded as a 64-bit integer. Not supported on Flash or Shockwave.
public long ReadLong()

Returns

long

Exceptions

UnsupportedClientException

If the Client is Flash or Shockwave.

ReadShort()

Reads a short from the current position and advances it.

Decoded as a B64 on Shockwave, otherwise as a 16-bit integer.
public short ReadShort()

Returns

short

ReadShortArray()

Reads a short array from the current position and advances it.

public short[] ReadShortArray()

Returns

short[]

ReadSpan(int)

Reads a Span<T> of bytes of length n from the current position and advances it.

public ReadOnlySpan<byte> ReadSpan(int n)

Parameters

n int

The number of bytes to read.

Returns

ReadOnlySpan<byte>

Exceptions

IndexOutOfRangeException

If the current position plus the specified length exceeds the length of the packet.

ReadString()

Reads a string from the current position and advances it.

On Shockwave, when the header direction is incoming, it is decoded as a sequence of characters terminated by a 0x02 byte.

Otherwise, it is decoded as a short length-prefixed UTF-8 string.
public string ReadString()

Returns

string

ReadStringArray()

Reads a string array from the current position and advances it.

public string[] ReadStringArray()

Returns

string[]

ReadVL64()

Reads a VL64 from the current position and advances it.

Not supported on Unity or Flash.
public VL64 ReadVL64()

Returns

VL64

Exceptions

UnsupportedClientException

If the Client is Unity or Flash.