Struct PacketReader
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
IPacketpos
intcontext
IParserContext
Fields
Pos
public readonly ref int Pos
Field Value
Properties
Available
public int Available { get; }
Property Value
Client
public ClientType Client { get; }
Property Value
Context
public IParserContext? Context { get; }
Property Value
Encoding
public Encoding Encoding { get; }
Property Value
Header
public Header Header { get; }
Property Value
Length
public int Length { get; }
Property Value
Span
public ReadOnlySpan<byte> Span { get; }
Property Value
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
Exceptions
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
ReadByte()
Reads a byte from the current position and advances it.
Not supported on Shockwave.public byte ReadByte()
Returns
Exceptions
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
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
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
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
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
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
Exceptions
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
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
intThe number of bytes to read.
Returns
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 a0x02
byte.
Otherwise, it is decoded as a short length-prefixed UTF-8 string.
public string ReadString()
Returns
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()