Table of Contents

Class NetBuffer

Namespace
SharpPluginLoader.Core.Networking
Assembly
SharpPluginLoader.Core.dll

Represents a network buffer used for reading and writing data.

public class NetBuffer
Inheritance
NetBuffer
Inherited Members

Constructors

NetBuffer(byte[])

Initializes a new instance of the NetBuffer class with the specified buffer.

public NetBuffer(byte[] buffer)

Parameters

buffer byte[]

The buffer to use.

NetBuffer(int)

Initializes a new instance of the NetBuffer class with the specified size.

public NetBuffer(int size)

Parameters

size int

The size of the buffer.

NetBuffer(ReadOnlySpan<byte>)

Initializes a new instance of the NetBuffer class with the specified buffer.

public NetBuffer(ReadOnlySpan<byte> buffer)

Parameters

buffer ReadOnlySpan<byte>

The buffer to use.

Properties

Buffer

Gets the buffer.

public ReadOnlySpan<byte> Buffer { get; }

Property Value

ReadOnlySpan<byte>

Size

Gets the size of the buffer.

public int Size { get; }

Property Value

int

Methods

ReadBoolean()

Reads a boolean value from the buffer and advances the position by 1.

public bool ReadBoolean()

Returns

bool

The boolean value read from the buffer.

ReadByte()

Reads a byte from the buffer and advances the position by 1.

public byte ReadByte()

Returns

byte

The byte value read from the buffer.

ReadBytes(int)

Reads a specified number of bytes from the buffer and advances the position by the number of bytes read.

public byte[] ReadBytes(int count)

Parameters

count int

The number of bytes to read.

Returns

byte[]

A byte array containing the bytes read from the buffer.

ReadDouble()

Reads a double-precision floating-point value from the buffer and advances the position by 8.

public double ReadDouble()

Returns

double

The double-precision floating-point value read from the buffer.

ReadFloat()

Reads a single-precision floating-point value from the buffer and advances the position by 4.

public float ReadFloat()

Returns

float

The single-precision floating-point value read from the buffer.

ReadInt16()

Reads a signed 16-bit integer from the buffer and advances the position by 2.

public short ReadInt16()

Returns

short

The signed 16-bit integer value read from the buffer.

ReadInt32()

Reads a signed 32-bit integer from the buffer and advances the position by 4.

public int ReadInt32()

Returns

int

The signed 32-bit integer value read from the buffer.

ReadInt64()

Reads a signed 64-bit integer from the buffer and advances the position by 8.

public long ReadInt64()

Returns

long

The signed 64-bit integer value read from the buffer.

ReadSByte()

Reads a signed byte from the buffer and advances the position by 1.

public sbyte ReadSByte()

Returns

sbyte

The signed byte value read from the buffer.

ReadString(int)

Reads a string from the buffer encoded in UTF-8 and advances the position by the length of the string.

public string ReadString(int count)

Parameters

count int

The number of bytes to read.

Returns

string

The string value read from the buffer.

ReadString(int, Encoding)

Reads a string from the buffer encoded in the specified encoding and advances the position by the length of the string.

public string ReadString(int count, Encoding encoding)

Parameters

count int

The number of bytes to read.

encoding Encoding

The encoding to use.

Returns

string

The string value read from the buffer.

ReadUInt16()

Reads an unsigned 16-bit integer from the buffer and advances the position by 2.

public ushort ReadUInt16()

Returns

ushort

The unsigned 16-bit integer value read from the buffer.

ReadUInt32()

Reads an unsigned 32-bit integer from the buffer and advances the position by 4.

public uint ReadUInt32()

Returns

uint

The unsigned 32-bit integer value read from the buffer.

ReadUInt64()

Reads an unsigned 64-bit integer from the buffer and advances the position by 8.

public ulong ReadUInt64()

Returns

ulong

The unsigned 64-bit integer value read from the buffer.

WriteBoolean(bool)

Writes a boolean value to the buffer and advances the position by 1.

public void WriteBoolean(bool value)

Parameters

value bool

The boolean value to write.

WriteByte(byte)

Writes a byte to the buffer and advances the position by 1.

public void WriteByte(byte value)

Parameters

value byte

The byte value to write.

WriteBytes(ReadOnlySpan<byte>)

Writes a byte array to the buffer and advances the position by the length of the array.

public void WriteBytes(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

The byte array to write.

WriteDouble(double)

Writes a double-precision floating-point value to the buffer and advances the position by 8.

public void WriteDouble(double value)

Parameters

value double

The double-precision floating-point value to write.

WriteFloat(float)

Writes a single-precision floating-point value to the buffer and advances the position by 4.

public void WriteFloat(float value)

Parameters

value float

The single-precision floating-point value to write.

WriteInt16(short)

Writes a signed 16-bit integer to the buffer and advances the position by 2.

public void WriteInt16(short value)

Parameters

value short

The signed 16-bit integer value to write.

WriteInt32(int)

Writes a signed 32-bit integer to the buffer and advances the position by 4.

public void WriteInt32(int value)

Parameters

value int

The signed 32-bit integer value to write.

WriteInt64(long)

Writes a signed 64-bit integer to the buffer and advances the position by 8.

public void WriteInt64(long value)

Parameters

value long

The signed 64-bit integer value to write.

WriteSByte(sbyte)

Writes a signed byte to the buffer and advances the position by 1.

public void WriteSByte(sbyte value)

Parameters

value sbyte

The signed byte value to write.

WriteString(string)

Writes a string encoded in UTF-8 to the buffer and advances the position by the length of the string.

public void WriteString(string value)

Parameters

value string

The string value to write.

WriteString(string, Encoding)

Writes a string encoded in the specified encoding to the buffer and advances the position by the length of the string.

public void WriteString(string value, Encoding encoding)

Parameters

value string

The string value to write.

encoding Encoding

The encoding to use.

WriteUInt16(ushort)

Writes an unsigned 16-bit integer to the buffer and advances the position by 2.

public void WriteUInt16(ushort value)

Parameters

value ushort

The unsigned 16-bit integer value to write.

WriteUInt32(uint)

Writes an unsigned 32-bit integer to the buffer and advances the position by 4.

public void WriteUInt32(uint value)

Parameters

value uint

The unsigned 32-bit integer value to write.

WriteUInt64(ulong)

Writes an unsigned 64-bit integer to the buffer and advances the position by 8.

public void WriteUInt64(ulong value)

Parameters

value ulong

The unsigned 64-bit integer value to write.