Show / Hide Table of Contents

    Class NetworkMessage

    Class that represents a network message.

    Inheritance
    System.Object
    NetworkMessage
    Implements
    INetworkMessage
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Fibula.Communications
    Assembly: Fibula.Communications.dll
    Syntax
    public class NetworkMessage : INetworkMessage

    Constructors

    | Improve this Doc View Source

    NetworkMessage(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 Source

    BufferSize

    The size of the message's buffer.

    Declaration
    public const int BufferSize = 16394
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DefaultStartingIndex

    The default index at which the message's content starts.

    Declaration
    public const int DefaultStartingIndex = 2
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    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 Source

    Buffer

    Gets the buffer of this message.

    Declaration
    public Span<byte> Buffer { get; }
    Property Value
    Type Description
    System.Span<System.Byte>
    | Improve this Doc View Source

    Cursor

    Gets the position that the message will read from next.

    Declaration
    public int Cursor { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Length

    Gets the length of the message.

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    AddByte(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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetByte()

    Reads a byte value from the message and advances the cursor.

    Declaration
    public byte GetByte()
    Returns
    Type Description
    System.Byte

    The value read.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetString()

    Reads a string value from the message.

    Declaration
    public string GetString()
    Returns
    Type Description
    System.String

    The value read.

    | Improve this Doc View Source

    GetUInt16()

    Reads an unsigned short value from the message.

    Declaration
    public ushort GetUInt16()
    Returns
    Type Description
    System.UInt16

    The value read.

    | Improve this Doc View Source

    GetUInt32()

    Reads an unsigned integer value from the message.

    Declaration
    public uint GetUInt32()
    Returns
    Type Description
    System.UInt32

    The value read.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    ReadAsBytesInfo()

    Reads information sent in the message as it's bytes representation.

    Declaration
    public IBytesInfo ReadAsBytesInfo()
    Returns
    Type Description
    IBytesInfo

    The default formatted information.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    Reset()

    Resets the message.

    Declaration
    public void Reset()
    | Improve this Doc View Source

    Resize(Int32, Boolean)

    Changes the Length of this message and resets it's Cursor.

    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.

    | Improve this Doc View Source

    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.

    Implements

    INetworkMessage

    Extension Methods

    ObjectExtensions.YieldSingleItem<T>(T)
    ObjectExtensions.GetPropertyValue(Object, String)
    Validate.ThrowIfNull(Object, String)
    NetworkMessageExtensions.XteaDecrypt(INetworkMessage, UInt32[])
    NetworkMessageExtensions.XteaEncrypt(INetworkMessage, UInt32[])
    NetworkMessageExtensions.PrepareToSend(INetworkMessage, UInt32[])
    NetworkMessageExtensions.AddLocation(INetworkMessage, Location)
    NetworkMessageExtensions.AddCreature(INetworkMessage, ICreature, Boolean, UInt32)
    NetworkMessageExtensions.AddOutfit(INetworkMessage, Outfit)
    NetworkMessageExtensions.AddItem(INetworkMessage, IItem)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2018-2020 | The Fibula Project
    Generated using DocFX | Jose L. Nuñez de Caceres et al.