Interface INetworkMessage
Interface that represents a network message.
Namespace: Fibula.Communications.Contracts.Abstractions
Assembly: Fibula.Communications.Contracts.dll
Syntax
public interface INetworkMessage
Properties
| Improve this Doc View SourceBuffer
Gets the byte buffer for this message.
Declaration
Span<byte> Buffer { get; }
Property Value
Type | Description |
---|---|
System.Span<System.Byte> |
Cursor
Gets the message position.
Declaration
int Cursor { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Length
Gets the message length.
Declaration
int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAddByte(Byte)
Adds a byte to the message.
Declaration
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
void AddBytes(ReadOnlySequence<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.Buffers.ReadOnlySequence<System.Byte> | value | The bytes span to add. |
AddBytes(ReadOnlySpan<Byte>)
Adds a byte range to the message.
Declaration
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
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
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
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
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.
Declaration
byte GetByte()
Returns
Type | Description |
---|---|
System.Byte | The value read. |
GetBytes(Int32)
Reads some bytes from the message.
Declaration
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
string GetString()
Returns
Type | Description |
---|---|
System.String | The value read. |
GetUInt16()
Reads an unsigned short value from the message.
Declaration
ushort GetUInt16()
Returns
Type | Description |
---|---|
System.UInt16 | The value read. |
GetUInt32()
Reads an unsigned integer value from the message.
Declaration
uint GetUInt32()
Returns
Type | Description |
---|---|
System.UInt32 | The value read. |
PeekByte()
Reads a byte value from the message without advancing the read cursor.
Declaration
byte PeekByte()
Returns
Type | Description |
---|---|
System.Byte | The value read. |
ReadAsBytesInfo()
Reads information sent in the message as bytes.
Declaration
IBytesInfo ReadAsBytesInfo()
Returns
Type | Description |
---|---|
IBytesInfo | The information read. |
ReadBytesFromStream(NetworkStream, UInt16)
Reads numberOfBytesToRead
bytes from the supplied network stream into the message buffer.
Declaration
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
void Reset()
Resize(Int32, Boolean)
Declaration
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
void SkipBytes(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The number of bytes to skip. |