Table of Contents

Class Packet

Namespace
Xabbo.Messages
Assembly
Xabbo.Common.dll

Represents a packet of data with a message header.

public sealed class Packet : IPacket, IDisposable
Inheritance
Packet
Implements

Constructors

Packet(Header, ClientType, PacketBuffer?)

Represents a packet of data with a message header.

public Packet(Header header, ClientType client = ClientType.None, PacketBuffer? buffer = null)

Parameters

header Header
client ClientType
buffer PacketBuffer

Properties

Available

public int Available { get; }

Property Value

int

Buffer

Gets the packet's buffer.

public PacketBuffer Buffer { get; }

Property Value

PacketBuffer

Client

Gets the client type of the packet's header.

public ClientType Client { get; set; }

Property Value

ClientType

Context

Gets the context this packet was intercepted in.

public IParserContext? Context { get; set; }

Property Value

IParserContext

Header

Gets or sets the message header of the packet.

public Header Header { get; set; }

Property Value

Header

Length

Gets the length of the packet.

public int Length { get; }

Property Value

int

Position

Gets a reference to the current position in the packet.

public ref int Position { get; }

Property Value

int

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>

Clear()

Clears the packet's buffer and resets its position.

public void Clear()

Copy()

public Packet Copy()

Returns

Packet

Dispose()

Disposes of this packet's buffer.

public void Dispose()

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

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.

Reader()

Creates a new reader for this packet at the current position.

public PacketReader Reader()

Returns

PacketReader

ReaderAt(ref int)

Creates a new reader for this packet at the specified position.

public PacketReader ReaderAt(ref int pos)

Parameters

pos int

Returns

PacketReader

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

WriteSpan(ReadOnlySpan<byte>)

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

public void WriteSpan(ReadOnlySpan<byte> span)

Parameters

span ReadOnlySpan<byte>

Writer()

Creates a new writer for this packet at the current position.

public PacketWriter Writer()

Returns

PacketWriter

WriterAt(ref int)

Creates a new writer for this packet at the specified position.

public PacketWriter WriterAt(ref int pos)

Parameters

pos int

Returns

PacketWriter