Table of Contents

Struct PacketWriter

Namespace
Xabbo.Messages
Assembly
Xabbo.Common.dll

Provides primitive packet write operations.

public readonly ref struct PacketWriter
Inherited Members

Constructors

PacketWriter(IPacket)

public PacketWriter(IPacket packet)

Parameters

packet IPacket

PacketWriter(IPacket, ref int, IParserContext?)

Provides primitive packet write operations.

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

Parameters

packet IPacket
pos int
context IParserContext

Fields

Context

public readonly IParserContext? Context

Field Value

IParserContext

Pos

public readonly ref int Pos

Field Value

int

Properties

Client

public ClientType Client { get; }

Property Value

ClientType

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 Span<byte> Span { get; }

Property Value

Span<byte>

Methods

Allocate(int)

Allocates the specified number of bytes from the current position and returns the allocated range as a Span<T> of bytes.

public Span<byte> Allocate(int n)

Parameters

n int

Returns

Span<byte>

ComposeArray<T>(IEnumerable<T>)

Composes the specified array of T to the current position and advances it.

public void ComposeArray<T>(IEnumerable<T> values) where T : IComposer

Parameters

values IEnumerable<T>

Type Parameters

T

Compose<T>(T)

Composes the specified T to the current position and advances it.

public void Compose<T>(T value) where T : IComposer

Parameters

value T

Type Parameters

T

Reader()

public PacketReader Reader()

Returns

PacketReader

ReaderAt(ref int)

public PacketReader ReaderAt(ref int pos)

Parameters

pos int

Returns

PacketReader

ReplaceB64(B64)

public void ReplaceB64(B64 value)

Parameters

value B64

ReplaceBool(bool)

public void ReplaceBool(bool value)

Parameters

value bool

ReplaceByte(byte)

public void ReplaceByte(byte value)

Parameters

value byte

ReplaceFloat(float)

public void ReplaceFloat(float value)

Parameters

value float

ReplaceId(Id)

public void ReplaceId(Id value)

Parameters

value Id

ReplaceInt(int)

public void ReplaceInt(int value)

Parameters

value int

ReplaceLength(Length)

public void ReplaceLength(Length value)

Parameters

value Length

ReplaceLong(long)

public void ReplaceLong(long value)

Parameters

value long

ReplaceShort(short)

public void ReplaceShort(short value)

Parameters

value short

ReplaceString(string)

public void ReplaceString(string value)

Parameters

value string

ReplaceStruct<T>(T)

public void ReplaceStruct<T>(T value) where T : IParserComposer<T>

Parameters

value T

Type Parameters

T

ReplaceVL64(VL64)

public void ReplaceVL64(VL64 value)

Parameters

value VL64

Resize(int, int)

Resizes a range of bytes from the current position of length <code class="paramref">pre</code> to length <code class="paramref">post</code> and returns the resized range as a Span<T> of bytes.

public Span<byte> Resize(int pre, int post)

Parameters

pre int

The length to resize from.

post int

The length to resize to

Returns

Span<byte>

The resized range as a Span<T> of bytes.

WriteB64(B64)

Writes the specified B64 value to the current position and advances it.

Not supported on Unity or Flash.
public void WriteB64(B64 value)

Parameters

value B64

Exceptions

UnsupportedClientException

If the Client is Unity or Flash.

WriteBool(bool)

Writes the specified bool value to the current position and advances it.

Encoded as a VL64 on Shockwave, otherwise as a byte .
public void WriteBool(bool value)

Parameters

value bool

WriteByte(byte)

Writes the specified byte value to the current position and advances it.

Not supported on Shockwave.
public void WriteByte(byte value)

Parameters

value byte

Exceptions

UnsupportedClientException

If the Client is Shockwave.

WriteContent(string)

Replaces the packet buffer with the specified content 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 void WriteContent(string content)

Parameters

content string

WriteFloat(float)

Writes the specified float value to the current position and advances it.

Written as a string on Flash and Shockwave, otherwise encoded as a 32-bit floating point number.
public void WriteFloat(float value)

Parameters

value float

WriteId(Id)

Writes the specified Id value to the current position and advances it.

Written as a long on Unity, or an int on Flash and Shockwave.
public void WriteId(Id value)

Parameters

value Id

Exceptions

UnsupportedClientException

If the client type is invalid.

WriteIdArray(IEnumerable<Id>)

Writes an Id array to the current position and advances it.

public void WriteIdArray(IEnumerable<Id> values)

Parameters

values IEnumerable<Id>

WriteInt(int)

Writes the specified int value to the current position and advances it.

Encoded as a VL64 on Shockwave, otherwise as a 32-bit integer.
public void WriteInt(int value)

Parameters

value int

WriteIntArray(IEnumerable<int>)

Writes an int array to the current position and advances it.

public void WriteIntArray(IEnumerable<int> values)

Parameters

values IEnumerable<int>

WriteLength(Length)

Writes the specified Length value to the current position and advances it.

Written as a short on Unity, or an int on Flash and Shockwave.
public void WriteLength(Length value)

Parameters

value Length

Exceptions

UnsupportedClientException

If the client type is invalid.

ArgumentOutOfRangeException

If the value is negative.

WriteLong(long)

Writes the specified long value to the current position and advances it.

Encoded as a 64-bit integer. Not supported on Flash or Shockwave.
public void WriteLong(long value)

Parameters

value long

Exceptions

UnsupportedClientException

If the Client is Flash or Shockwave.

WriteShort(short)

Writes the specified short value to the current position and advances it.

Encoded as a B64 on Shockwave, otherwise as a 16-bit integer.
public void WriteShort(short value)

Parameters

value short

WriteShortArray(IEnumerable<short>)

Writes a short array to the current position and advances it.

public void WriteShortArray(IEnumerable<short> values)

Parameters

values IEnumerable<short>

WriteSpan(ReadOnlySpan<byte>)

Writes the specified Span<T> of bytes to the current position.

public void WriteSpan(ReadOnlySpan<byte> span)

Parameters

span ReadOnlySpan<byte>

WriteString(string)

Writes the specified string value to the current position and advances it.

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

Otherwise, it is encoded as a short length-prefixed UTF-8 string.
public void WriteString(string value)

Parameters

value string

Exceptions

ArgumentException

If the string length exceeds the maximum value of an unsigned 16-bit integer.

ArgumentNullException

If the string is null.

WriteStringArray(IEnumerable<string>)

Writes a string array to the current position and advances it.

public void WriteStringArray(IEnumerable<string> values)

Parameters

values IEnumerable<string>

WriteVL64(VL64)

Writes the specified VL64 value to the current position and advances it.

Not supported on Unity or Flash.
public void WriteVL64(VL64 value)

Parameters

value VL64

Exceptions

UnsupportedClientException

If the Client is Unity or Flash.

WriterAt(ref int)

public PacketWriter WriterAt(ref int pos)

Parameters

pos int

Returns

PacketWriter