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
intThe 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
Size
Gets the size of the buffer.
public int Size { get; }
Property Value
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
intThe 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
intThe 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
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
boolThe 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
byteThe 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
doubleThe 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
floatThe 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
shortThe 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
intThe 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
longThe 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
sbyteThe 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
stringThe 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
WriteUInt16(ushort)
Writes an unsigned 16-bit integer to the buffer and advances the position by 2.
public void WriteUInt16(ushort value)
Parameters
value
ushortThe 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
uintThe 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
ulongThe unsigned 64-bit integer value to write.