Struct PacketWriter
Provides primitive packet write operations.
public readonly ref struct PacketWriter
  - Inherited Members
 
Constructors
PacketWriter(IPacket)
public PacketWriter(IPacket packet)
  Parameters
packetIPacket
PacketWriter(IPacket, ref int, IParserContext?)
Provides primitive packet write operations.
public PacketWriter(IPacket packet, ref int pos, IParserContext? context = null)
  Parameters
packetIPacketposintcontextIParserContext
Fields
Context
public readonly IParserContext? Context
  Field Value
Pos
public readonly ref int Pos
  Field Value
Properties
Client
public ClientType Client { 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 Span<byte> Span { 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
nint
Returns
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
valuesIEnumerable<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
valueT
Type Parameters
T
Reader()
public PacketReader Reader()
  Returns
ReaderAt(ref int)
public PacketReader ReaderAt(ref int pos)
  Parameters
posint
Returns
ReplaceB64(B64)
public void ReplaceB64(B64 value)
  Parameters
valueB64
ReplaceBool(bool)
public void ReplaceBool(bool value)
  Parameters
valuebool
ReplaceByte(byte)
public void ReplaceByte(byte value)
  Parameters
valuebyte
ReplaceFloat(float)
public void ReplaceFloat(float value)
  Parameters
valuefloat
ReplaceId(Id)
public void ReplaceId(Id value)
  Parameters
valueId
ReplaceInt(int)
public void ReplaceInt(int value)
  Parameters
valueint
ReplaceLength(Length)
public void ReplaceLength(Length value)
  Parameters
valueLength
ReplaceLong(long)
public void ReplaceLong(long value)
  Parameters
valuelong
ReplaceShort(short)
public void ReplaceShort(short value)
  Parameters
valueshort
ReplaceString(string)
public void ReplaceString(string value)
  Parameters
valuestring
ReplaceStruct<T>(T)
public void ReplaceStruct<T>(T value) where T : IParserComposer<T>
  Parameters
valueT
Type Parameters
T
ReplaceVL64(VL64)
public void ReplaceVL64(VL64 value)
  Parameters
valueVL64
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
Returns
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
valueB64
Exceptions
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
valuebool
WriteByte(byte)
Writes the specified byte value to the current position and advances it.
Not supported on Shockwave.public void WriteByte(byte value)
  Parameters
valuebyte
Exceptions
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
contentstring
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
valuefloat
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
valueId
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
valuesIEnumerable<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
valueint
WriteIntArray(IEnumerable<int>)
Writes an int array to the current position and advances it.
public void WriteIntArray(IEnumerable<int> values)
  Parameters
valuesIEnumerable<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
valueLength
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
valuelong
Exceptions
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
valueshort
WriteShortArray(IEnumerable<short>)
Writes a short array to the current position and advances it.
public void WriteShortArray(IEnumerable<short> values)
  Parameters
valuesIEnumerable<short>
WriteSpan(ReadOnlySpan<byte>)
Writes the specified Span<T> of bytes to the current position.
public void WriteSpan(ReadOnlySpan<byte> span)
  Parameters
spanReadOnlySpan<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 a0x02 byte.
Otherwise, it is encoded as a short length-prefixed UTF-8 string.
public void WriteString(string value)
  Parameters
valuestring
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
valuesIEnumerable<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
valueVL64
Exceptions
WriterAt(ref int)
public PacketWriter WriterAt(ref int pos)
  Parameters
posint