Search Results for

    Show / Hide Table of Contents

    Class NetworkStream

    Objects and values serialization stream for sending data over network. Uses memory buffer for both read and write operations.

    Inheritance
    System.Object
    Object
    NetworkStream
    Inherited Members
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine.Networking
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public sealed class NetworkStream : Object

    Constructors

    NetworkStream()

    Initializes a new instance of the NetworkStream.

    Declaration
    public NetworkStream()

    Properties

    Buffer

    Gets the pointer to the native stream memory buffer.

    Declaration
    [Unmanaged]
    public byte *Buffer { get; }
    Property Value
    System.Byte*

    SenderId

    The ClientId of the network client that is a data sender. Can be used to detect who send the incoming RPC or replication data. Set to the current client when writing data.

    Declaration
    [Unmanaged]
    public uint SenderId { get; }
    Property Value
    System.UInt32

    Methods

    Initialize(Byte*, UInt32)

    Initializes the stream for reading.

    Declaration
    [Unmanaged]
    public void Initialize(byte *buffer, uint length)
    Parameters
    System.Byte* buffer

    The allocated memory.

    System.UInt32 length

    The allocated memory length (bytes count).

    Initialize(UInt32)

    Initializes the stream for writing. Allocates the memory or reuses already existing memory. Resets the current stream position to beginning.

    Declaration
    [Unmanaged]
    public void Initialize(uint minCapacity = 1024U)
    Parameters
    System.UInt32 minCapacity

    The minimum capacity (in bytes) for the memory buffer used for data storage.

    Read(INetworkSerializable)

    Reads the INetworkSerializable object data from the stream. Object has to be allocated.

    Declaration
    public void Read(INetworkSerializable obj)
    Parameters
    INetworkSerializable obj

    The serializable object.

    ReadBoolean()

    Reads and returns data of type System.Boolean from the message.

    Declaration
    public bool ReadBoolean()
    Returns
    System.Boolean

    ReadByte()

    Reads and returns data of type System.Byte from the message.

    Declaration
    public byte ReadByte()
    Returns
    System.Byte

    ReadBytes(Byte*, Int32)

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

    Declaration
    public void ReadBytes(byte *buffer, int length)
    Parameters
    System.Byte* buffer

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

    System.Int32 length

    The minimal amount of bytes that the buffer contains.

    ReadBytes(Byte[], Int32)

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

    Declaration
    public void ReadBytes(byte[] buffer, int length)
    Parameters
    System.Byte[] buffer

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

    System.Int32 length

    The minimal amount of bytes that the buffer contains.

    ReadData(IntPtr, Int32)

    Reads bytes from the stream

    Declaration
    [Unmanaged]
    public void ReadData(IntPtr data, int bytes)
    Parameters
    System.IntPtr data

    Data to write

    System.Int32 bytes

    Amount of bytes to write

    ReadDouble()

    Reads and returns data of type System.Double from the message.

    Declaration
    public double ReadDouble()
    Returns
    System.Double

    ReadFloat2()

    Reads and returns data of type Float2 from the message.

    Declaration
    public Float2 ReadFloat2()
    Returns
    Float2

    ReadFloat3()

    Reads and returns data of type Float3 from the message.

    Declaration
    public Float3 ReadFloat3()
    Returns
    Float3

    ReadFloat4()

    Reads and returns data of type Float4 from the message.

    Declaration
    public Float4 ReadFloat4()
    Returns
    Float4

    ReadGuid()

    Reads and returns data of type System.Guid from the message.

    Declaration
    public Guid ReadGuid()
    Returns
    System.Guid

    ReadInt16()

    Reads and returns data of type System.Int16 from the message.

    Declaration
    public short ReadInt16()
    Returns
    System.Int16

    ReadInt32()

    Reads and returns data of type System.Int32 from the message.

    Declaration
    public int ReadInt32()
    Returns
    System.Int32

    ReadInt64()

    Reads and returns data of type System.Int64 from the message.

    Declaration
    public long ReadInt64()
    Returns
    System.Int64

    ReadQuaternion()

    Reads and returns data of type Quaternion from the message.

    Declaration
    public Quaternion ReadQuaternion()
    Returns
    Quaternion

    ReadRay()

    Reads and returns data of type Ray from the message.

    Declaration
    public Ray ReadRay()
    Returns
    Ray

    ReadSByte()

    Reads and returns data of type System.SByte from the message.

    Declaration
    public sbyte ReadSByte()
    Returns
    System.SByte

    ReadSingle()

    Reads and returns data of type System.Single from the message.

    Declaration
    public float ReadSingle()
    Returns
    System.Single

    ReadString()

    Reads and returns data of type System.String from the message. UTF-16 encoded.

    Declaration
    public string ReadString()
    Returns
    System.String

    ReadUInt16()

    Reads and returns data of type System.UInt16 from the message.

    Declaration
    public ushort ReadUInt16()
    Returns
    System.UInt16

    ReadUInt32()

    Reads and returns data of type System.UInt32 from the message.

    Declaration
    public uint ReadUInt32()
    Returns
    System.UInt32

    ReadUInt64()

    Reads and returns data of type System.UInt64 from the message.

    Declaration
    public ulong ReadUInt64()
    Returns
    System.UInt64

    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

    Write(INetworkSerializable)

    Writes the INetworkSerializable object data to the stream. Object has to be allocated.

    Declaration
    public void Write(INetworkSerializable obj)
    Parameters
    INetworkSerializable obj

    The serializable object.

    WriteBoolean(Boolean)

    Writes data of type System.Boolean into the message.

    Declaration
    public void WriteBoolean(bool value)
    Parameters
    System.Boolean value

    WriteByte(Byte)

    Writes data of type System.Byte into the message.

    Declaration
    public void WriteByte(byte value)
    Parameters
    System.Byte value

    WriteBytes(Byte*, Int32)

    Writes raw bytes into the message.

    Declaration
    public void WriteBytes(byte *bytes, int length)
    Parameters
    System.Byte* bytes

    The bytes that will be written.

    System.Int32 length

    The amount of bytes to write from the bytes pointer.

    WriteBytes(Byte[], Int32)

    Writes raw bytes into the message.

    Declaration
    public void WriteBytes(byte[] bytes, int length)
    Parameters
    System.Byte[] bytes

    The bytes that will be written.

    System.Int32 length

    The amount of bytes to write from the bytes array.

    WriteData(IntPtr, Int32)

    Writes bytes to the stream

    Declaration
    [Unmanaged]
    public void WriteData(IntPtr data, int bytes)
    Parameters
    System.IntPtr data

    Data to write

    System.Int32 bytes

    Amount of bytes to write

    WriteDouble(Double)

    Writes data of type System.Double into the message.

    Declaration
    public void WriteDouble(double value)
    Parameters
    System.Double value

    WriteFloat2(Float2)

    Writes data of type Float2 into the message.

    Declaration
    public void WriteFloat2(Float2 value)
    Parameters
    Float2 value

    WriteFloat3(Float3)

    Writes data of type Float3 into the message.

    Declaration
    public void WriteFloat3(Float3 value)
    Parameters
    Float3 value

    WriteFloat4(Float4)

    Writes data of type Float4 into the message.

    Declaration
    public void WriteFloat4(Float4 value)
    Parameters
    Float4 value

    WriteGuid(Guid)

    Writes data of type System.Guid into the message.

    Declaration
    public void WriteGuid(Guid value)
    Parameters
    System.Guid value

    WriteInt16(Int16)

    Writes data of type System.Int16 into the message.

    Declaration
    public void WriteInt16(short value)
    Parameters
    System.Int16 value

    WriteInt32(Int32)

    Writes data of type System.Int32 into the message.

    Declaration
    public void WriteInt32(int value)
    Parameters
    System.Int32 value

    WriteInt64(Int64)

    Writes data of type System.Int64 into the message.

    Declaration
    public void WriteInt64(long value)
    Parameters
    System.Int64 value

    WriteQuaternion(Quaternion)

    Writes data of type Quaternion into the message.

    Declaration
    public void WriteQuaternion(Quaternion value)
    Parameters
    Quaternion value

    WriteRay(Ray)

    Writes data of type Ray into the message.

    Declaration
    public void WriteRay(Ray value)
    Parameters
    Ray value

    WriteSByte(SByte)

    Writes data of type System.SByte into the message.

    Declaration
    public void WriteSByte(sbyte value)
    Parameters
    System.SByte value

    WriteSingle(Single)

    Writes data of type System.Single into the message.

    Declaration
    public void WriteSingle(float value)
    Parameters
    System.Single value

    WriteString(String)

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

    Declaration
    public void WriteString(string value)
    Parameters
    System.String value

    WriteUInt16(UInt16)

    Writes data of type System.UInt16 into the message.

    Declaration
    public void WriteUInt16(ushort value)
    Parameters
    System.UInt16 value

    WriteUInt32(UInt32)

    Writes data of type System.UInt32 into the message.

    Declaration
    public void WriteUInt32(uint value)
    Parameters
    System.UInt32 value

    WriteUInt64(UInt64)

    Writes data of type System.UInt64 into the message.

    Declaration
    public void WriteUInt64(ulong value)
    Parameters
    System.UInt64 value

    WriteVector2(Vector2)

    Writes data of type Vector2 into the message.

    Declaration
    public void WriteVector2(Vector2 value)
    Parameters
    Vector2 value

    WriteVector3(Vector3)

    Writes data of type Vector3 into the message.

    Declaration
    public void WriteVector3(Vector3 value)
    Parameters
    Vector3 value

    WriteVector4(Vector4)

    Writes data of type Vector4 into the message.

    Declaration
    public void WriteVector4(Vector4 value)
    Parameters
    Vector4 value

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat