Search Results for

    Show / Hide Table of Contents

    Struct NetworkMessage

    Network message structure. Provides raw data writing and reading to the message buffer.

    Assembly: FlaxEngine.dll
    File: Engine/Networking/NetworkMessage.h
    Syntax
    public struct NetworkMessage

    Constructors

    ~NetworkMessage()

    Declaration
    public ~NetworkMessage() = default

    NetworkMessage()

    Initializes default values of the

    NetworkMessage

    structure.

    Declaration
    public NetworkMessage() = default

    NetworkMessage(uint8* buffer, uint32 messageId, uint32 bufferSize, uint32 length, uint32 position)

    Initializes values of the

    NetworkMessage

    structure.

    Declaration
    public NetworkMessage(uint8* buffer, uint32 messageId, uint32 bufferSize, uint32 length, uint32 position)
    Parameters
    uint8 buffer

    uint32 messageId

    uint32 bufferSize

    uint32 length

    uint32 position

    Fields

    Buffer

    The raw message buffer.

    Declaration
    public uint8* Buffer = nullptr
    Field Value
    uint8

    BufferSize

    The size in bytes of the buffer that this message has.

    Declaration
    public uint32 BufferSize = 0
    Field Value
    uint32

    Length

    The length in bytes of this message.

    Declaration
    public uint32 Length = 0
    Field Value
    uint32

    MessageId

    The unique, internal message identifier.

    Declaration
    public uint32 MessageId = 0
    Field Value
    uint32

    Position

    The position in bytes in buffer where the next read/write will occur.

    Declaration
    public uint32 Position = 0
    Field Value
    uint32

    Methods

    IsValid()

    Returns true if the message is valid for reading or writing.

    Declaration
    public bool IsValid() const
    Returns
    bool

    ReadBytes(uint8* bytes, const int32 numBytes)

    Reads raw bytes from the message into the given byte array.

    Declaration
    public void ReadBytes(uint8* bytes, const int32 numBytes)
    Parameters
    uint8 bytes

    The buffer pointer that will be used to store the bytes. Should be of the same length as length or longer.

    int32 numBytes

    The minimal amount of bytes that the buffer contains.

    Returns
    void

    ReadGuid()

    Reads and returns data of type Guid from the message.

    Declaration
    public Guid ReadGuid()
    Returns
    Guid

    ReadNetworkId(Guid& id)

    Reads identifier from the stream that is networked-synced (by a server). If both peers acknowledge a specific id then the data transfer is optimized to 32 bits.

    Declaration
    public void ReadNetworkId(Guid& id)
    Parameters
    Guid id

    Network-synced identifier.

    ReadNetworkName(StringAnsiView& name)

    Reads name from the stream that is networked-synced (by a server). If both peers acknowledge a specific name then the data transfer is optimized to 32 bits.

    Declaration
    public void ReadNetworkName(StringAnsiView& name)
    Parameters
    StringAnsiView name

    Network-synced name.

    ReadQuaternion()

    Reads and returns data of type Quaternion from the message.

    Declaration
    public Quaternion ReadQuaternion()
    Returns
    Quaternion

    ReadString()

    Reads and returns data of type String from the message. UTF-16 encoded. Data valid within message lifetime.

    Declaration
    public StringView ReadString()
    Returns
    StringView

    ReadStringAnsi()

    Reads and returns data of type String from the message. ANSI encoded. Data valid within message lifetime.

    Declaration
    public StringAnsiView ReadStringAnsi()
    Returns
    StringAnsiView

    ReadStructure(const T& data)

    Declaration
    public void ReadStructure(const T& data)
    Parameters
    T data

    Returns
    void

    Type Parameters
    typename T

    ReadVector2()

    Reads and returns data of type Vector2 from the message.

    Declaration
    public Vector2 ReadVector2()
    Returns
    Vector2

    ReadVector3()

    Reads and returns data of type Vector3 from the message.

    Declaration
    public Vector3 ReadVector3()
    Returns
    Vector3

    ReadVector4()

    Reads and returns data of type Vector4 from the message.

    Declaration
    public Vector4 ReadVector4()
    Returns
    Vector4

    SkipBytes(const int32 numBytes)

    Skips bytes from the message.

    Declaration
    public void* SkipBytes(const int32 numBytes)
    Parameters
    int32 numBytes

    Amount of bytes to skip.

    Returns
    void

    Pointer to skipped data beginning.

    WriteBytes(const uint8* bytes, const int32 numBytes)

    Writes raw bytes into the message.

    Declaration
    public void WriteBytes(const uint8* bytes, const int32 numBytes)
    Parameters
    uint8 bytes

    The bytes that will be written.

    int32 numBytes

    The amount of bytes to write from the bytes pointer.

    Returns
    void

    WriteGuid(const Guid& value)

    Writes data of type Guid into the message.

    Declaration
    public void WriteGuid(const Guid& value)
    Parameters
    Guid value

    Returns
    void

    WriteNetworkId(const Guid& id)

    Writes identifier into the stream that is networked-synced (by a server). If both peers acknowledge a specific id then the data transfer is optimized to 32 bits.

    Declaration
    public void WriteNetworkId(const Guid& id)
    Parameters
    Guid id

    Network-synced identifier.

    WriteNetworkName(const StringAnsiView& name)

    Writes name into the stream that is networked-synced (by a server). If both peers acknowledge a specific name then the data transfer is optimized to 32 bits.

    Declaration
    public void WriteNetworkName(const StringAnsiView& name)
    Parameters
    StringAnsiView name

    Network-synced name.

    WriteQuaternion(const Quaternion& value)

    Writes data of type Quaternion into the message.

    Declaration
    public void WriteQuaternion(const Quaternion& value)
    Parameters
    Quaternion value

    Returns
    void

    WriteString(const StringView& value)

    Writes data of type String into the message. UTF-16 encoded.

    Declaration
    public void WriteString(const StringView& value)
    Parameters
    StringView value

    Returns
    void

    WriteStringAnsi(const StringAnsiView& value)

    Writes data of type String into the message.

    Declaration
    public void WriteStringAnsi(const StringAnsiView& value)
    Parameters
    StringAnsiView value

    Returns
    void

    WriteStructure(const T& data)

    Declaration
    public void WriteStructure(const T& data)
    Parameters
    T data

    Returns
    void

    Type Parameters
    typename T

    WriteVector2(const Vector2& value)

    Writes data of type Vector2 into the message.

    Declaration
    public void WriteVector2(const Vector2& value)
    Parameters
    Vector2 value

    Returns
    void

    WriteVector3(const Vector3& value)

    Writes data of type Vector3 into the message.

    Declaration
    public void WriteVector3(const Vector3& value)
    Parameters
    Vector3 value

    Returns
    void

    WriteVector4(const Vector4& value)

    Writes data of type Vector4 into the message.

    Declaration
    public void WriteVector4(const Vector4& value)
    Parameters
    Vector4 value

    Returns
    void

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat