NetBuffer
Namespace: SharpPluginLoader.Core.Networking
Represents a network buffer used for reading and writing data.
public class NetBuffer
Inheritance Object → NetBuffer
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
Constructors
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.
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(Int32)
Initializes a new instance of the NetBuffer class with the specified size.
public NetBuffer(int size)
Parameters
size
Int32
The size of the buffer.
Methods
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.
WriteUInt16(UInt16)
Writes an unsigned 16-bit integer to the buffer and advances the position by 2.
public void WriteUInt16(ushort value)
Parameters
value
UInt16
The unsigned 16-bit integer value to write.
WriteUInt32(UInt32)
Writes an unsigned 32-bit integer to the buffer and advances the position by 4.
public void WriteUInt32(uint value)
Parameters
value
UInt32
The unsigned 32-bit integer value to write.
WriteUInt64(UInt64)
Writes an unsigned 64-bit integer to the buffer and advances the position by 8.
public void WriteUInt64(ulong value)
Parameters
value
UInt64
The unsigned 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.
WriteInt16(Int16)
Writes a signed 16-bit integer to the buffer and advances the position by 2.
public void WriteInt16(short value)
Parameters
value
Int16
The signed 16-bit integer value to write.
WriteInt32(Int32)
Writes a signed 32-bit integer to the buffer and advances the position by 4.
public void WriteInt32(int value)
Parameters
value
Int32
The signed 32-bit integer value to write.
WriteInt64(Int64)
Writes a signed 64-bit integer to the buffer and advances the position by 8.
public void WriteInt64(long value)
Parameters
value
Int64
The signed 64-bit integer value to write.
WriteFloat(Single)
Writes a single-precision floating-point value to the buffer and advances the position by 4.
public void WriteFloat(float value)
Parameters
value
Single
The single-precision floating-point value 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.
WriteBoolean(Boolean)
Writes a boolean value to the buffer and advances the position by 1.
public void WriteBoolean(bool value)
Parameters
value
Boolean
The boolean 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.
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.
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.
ReadUInt16()
Reads an unsigned 16-bit integer from the buffer and advances the position by 2.
public ushort ReadUInt16()
Returns
UInt16
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
UInt32
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
UInt64
The unsigned 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.
ReadInt16()
Reads a signed 16-bit integer from the buffer and advances the position by 2.
public short ReadInt16()
Returns
Int16
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
Int32
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
Int64
The signed 64-bit integer 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
Single
The single-precision floating-point value 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.
ReadBoolean()
Reads a boolean value from the buffer and advances the position by 1.
public bool ReadBoolean()
Returns
Boolean
The boolean value read from the buffer.
ReadBytes(Int32)
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
Int32
The number of bytes to read.
Returns
Byte[]
A byte array containing the bytes read from the buffer.
ReadString(Int32)
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
Int32
The number of bytes to read.
Returns
String
The string value read from the buffer.
ReadString(Int32, 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
Int32
The number of bytes to read.
encoding
Encoding
The encoding to use.
Returns
String
The string value read from the buffer.