Class NetworkMessage
Class that represents a network message.
Inheritance
Implements
Inherited Members
Namespace: Fibula.Communications
Assembly: Fibula.Communications.dll
Syntax
public class NetworkMessage : INetworkMessage
Constructors
| Improve this Doc View SourceNetworkMessage(Boolean)
Initializes a new instance of the NetworkMessage class.
Declaration
public NetworkMessage(bool isOutbound = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isOutbound | A value indicating whether this message is an outboud message. |
Fields
| Improve this Doc View SourceBufferSize
The size of the message's buffer.
Declaration
public const int BufferSize = 16394
Field Value
Type | Description |
---|---|
System.Int32 |
DefaultStartingIndex
The default index at which the message's content starts.
Declaration
public const int DefaultStartingIndex = 2
Field Value
Type | Description |
---|---|
System.Int32 |
OutboundMessageStartingIndex
The number of reserved bytes in the network message for outbound messages.
Declaration
public const int OutboundMessageStartingIndex = 4
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceBuffer
Gets the buffer of this message.
Declaration
public Span<byte> Buffer { get; }
Property Value
Type | Description |
---|---|
System.Span<System.Byte> |
Cursor
Gets the position that the message will read from next.
Declaration
public int Cursor { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Length
Gets the length of the message.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAddByte(Byte)
Adds a byte to the message.
Declaration
public void AddByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The byte value to add. |
AddBytes(ReadOnlySequence<Byte>)
Adds a byte sequence to the message.
Declaration
public void AddBytes(ReadOnlySequence<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.Buffers.ReadOnlySequence<System.Byte> | value | The bytes to add. |
AddBytes(ReadOnlySpan<Byte>)
Adds a byte range to the message.
Declaration
public void AddBytes(ReadOnlySpan<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Byte> | value | The bytes to add. |
AddString(String)
Add a string to the message.
Declaration
public void AddString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to add. |
AddUInt16(UInt16)
Add an unsigned short integer to the message.
Declaration
public void AddUInt16(ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value to add. |
AddUInt32(UInt32)
Add an unsigned integer to the message.
Declaration
public void AddUInt32(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | The value to add. |
Copy(Nullable<Int32>)
Creates a copy of this message.
Declaration
public INetworkMessage Copy(int? overrideCursor = default(int? ))
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | overrideCursor | Optional. A value to override the cursor with. |
Returns
Type | Description |
---|---|
INetworkMessage | The copy of the message. |
GetByte()
Reads a byte value from the message and advances the cursor.
Declaration
public byte GetByte()
Returns
Type | Description |
---|---|
System.Byte | The value read. |
GetBytes(Int32)
Reads some bytes from the message.
Declaration
public ReadOnlySpan<byte> GetBytes(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The number of bytes to read. |
Returns
Type | Description |
---|---|
System.ReadOnlySpan<System.Byte> | The bytes read. |
GetString()
Reads a string value from the message.
Declaration
public string GetString()
Returns
Type | Description |
---|---|
System.String | The value read. |
GetUInt16()
Reads an unsigned short value from the message.
Declaration
public ushort GetUInt16()
Returns
Type | Description |
---|---|
System.UInt16 | The value read. |
GetUInt32()
Reads an unsigned integer value from the message.
Declaration
public uint GetUInt32()
Returns
Type | Description |
---|---|
System.UInt32 | The value read. |
PeekByte()
Reads a byte value from the message without advancing the read cursor.
Declaration
public byte PeekByte()
Returns
Type | Description |
---|---|
System.Byte | The value read. |
ReadAsBytesInfo()
Reads information sent in the message as it's bytes representation.
Declaration
public IBytesInfo ReadAsBytesInfo()
Returns
Type | Description |
---|---|
IBytesInfo | The default formatted information. |
ReadBytesFromStream(NetworkStream, UInt16)
Reads numberOfBytesToRead
bytes from the supplied network stream into the message buffer.
Declaration
public void ReadBytesFromStream(NetworkStream stream, ushort numberOfBytesToRead)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Sockets.NetworkStream | stream | The stream to read from. |
System.UInt16 | numberOfBytesToRead | The number of bytes to read. |
Reset()
Resets the message.
Declaration
public void Reset()
Resize(Int32, Boolean)
Declaration
public void Resize(int size, bool resetCursor = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The new size of the message. |
System.Boolean | resetCursor | Optional. A value indicating whether to reset the cursor in the message to zero. |
SkipBytes(Int32)
Moves the read pointer in the message, essentially skipping a number of bytes.
Declaration
public void SkipBytes(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The number of bytes to skip. |