Class Packet
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
Headerclient
ClientTypebuffer
PacketBuffer
Properties
Available
public int Available { get; }
Property Value
Buffer
Gets the packet's buffer.
public PacketBuffer Buffer { get; }
Property Value
Client
Gets the client type of the packet's header.
public ClientType Client { get; set; }
Property Value
Context
Gets the context this packet was intercepted in.
public IParserContext? Context { get; set; }
Property Value
Header
Gets or sets the message header of the packet.
public Header Header { get; set; }
Property Value
Length
Gets the length of the packet.
public int Length { get; }
Property Value
Position
Gets a reference to the current position in the packet.
public ref int Position { get; }
Property Value
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
Clear()
Clears the packet's buffer and resets its position.
public void Clear()
Copy()
public Packet Copy()
Returns
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
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
intThe number of bytes to read.
Returns
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
ReaderAt(ref int)
Creates a new reader for this packet at the specified position.
public PacketReader ReaderAt(ref int pos)
Parameters
pos
int
Returns
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
WriterAt(ref int)
Creates a new writer for this packet at the specified position.
public PacketWriter WriterAt(ref int pos)
Parameters
pos
int