Class NetworkStream
Objects and values serialization stream for sending data over network. Uses memory buffer for both read and write operations.
Namespace: FlaxEngine.Networking
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public sealed class NetworkStream : Object
Constructors
NetworkStream()
Properties
Buffer
Gets the pointer to the native stream memory buffer.
Declaration
[Unmanaged]
public byte *Buffer { get; }
Property Value
System.
|
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.
|
Methods
Initialize(Byte*, UInt32)
Initializes the stream for reading.
Declaration
[Unmanaged]
public void Initialize(byte *buffer, uint length)
Parameters
System. The allocated memory. |
System. 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. The minimum capacity (in bytes) for the memory buffer used for data storage. |
Read(INetworkSerializable)
Reads the INetwork
Declaration
public void Read(INetworkSerializable obj)
Parameters
INetwork The serializable object. |
ReadBoolean()
Reads and returns data of type System.
Declaration
public bool ReadBoolean()
Returns
System.
|
ReadByte()
Reads and returns data of type System.
Declaration
public byte ReadByte()
Returns
System.
|
ReadBytes(Byte*, Int32)
Reads raw bytes from the message into the given byte array.
Declaration
public void ReadBytes(byte *buffer, int length)
Parameters
System. The buffer pointer that will be used to store the bytes. Should be of the same length as length or longer. |
System. 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. The buffer that will be used to store the bytes. Should be of the same length as length or longer. |
System. 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. Data to write |
System. Amount of bytes to write |
ReadDouble()
Reads and returns data of type System.
Declaration
public double ReadDouble()
Returns
System.
|
ReadFloat2()
Reads and returns data of type Float2 from the message.
Declaration
public Float2 ReadFloat2()
Returns
ReadFloat3()
Reads and returns data of type Float3 from the message.
Declaration
public Float3 ReadFloat3()
Returns
ReadFloat4()
Reads and returns data of type Float4 from the message.
Declaration
public Float4 ReadFloat4()
Returns
ReadGuid()
Reads and returns data of type System.
Declaration
public Guid ReadGuid()
Returns
System.
|
ReadInt16()
Reads and returns data of type System.
Declaration
public short ReadInt16()
Returns
System.
|
ReadInt32()
Reads and returns data of type System.
Declaration
public int ReadInt32()
Returns
System.
|
ReadInt64()
Reads and returns data of type System.
Declaration
public long ReadInt64()
Returns
System.
|
ReadQuaternion()
Reads and returns data of type Quaternion from the message.
Declaration
public Quaternion ReadQuaternion()
Returns
ReadRay()
ReadSByte()
Reads and returns data of type System.
Declaration
public sbyte ReadSByte()
Returns
System.
|
ReadSingle()
Reads and returns data of type System.
Declaration
public float ReadSingle()
Returns
System.
|
ReadString()
Reads and returns data of type System.
Declaration
public string ReadString()
Returns
System.
|
ReadUInt16()
Reads and returns data of type System.
Declaration
public ushort ReadUInt16()
Returns
System.
|
ReadUInt32()
Reads and returns data of type System.
Declaration
public uint ReadUInt32()
Returns
System.
|
ReadUInt64()
Reads and returns data of type System.
Declaration
public ulong ReadUInt64()
Returns
System.
|
ReadVector2()
Reads and returns data of type Vector2 from the message.
Declaration
public Vector2 ReadVector2()
Returns
ReadVector3()
Reads and returns data of type Vector3 from the message.
Declaration
public Vector3 ReadVector3()
Returns
ReadVector4()
Reads and returns data of type Vector4 from the message.
Declaration
public Vector4 ReadVector4()
Returns
Write(INetworkSerializable)
Writes the INetwork
Declaration
public void Write(INetworkSerializable obj)
Parameters
INetwork The serializable object. |
WriteBoolean(Boolean)
Writes data of type System.
Declaration
public void WriteBoolean(bool value)
Parameters
System.
|
WriteByte(Byte)
Writes data of type System.
Declaration
public void WriteByte(byte value)
Parameters
System.
|
WriteBytes(Byte*, Int32)
Writes raw bytes into the message.
Declaration
public void WriteBytes(byte *bytes, int length)
Parameters
System. The bytes that will be written. |
System. 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. The bytes that will be written. |
System. 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. Data to write |
System. Amount of bytes to write |
WriteDouble(Double)
Writes data of type System.
Declaration
public void WriteDouble(double value)
Parameters
System.
|
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.
Declaration
public void WriteGuid(Guid value)
Parameters
System.
|
WriteInt16(Int16)
Writes data of type System.
Declaration
public void WriteInt16(short value)
Parameters
System.
|
WriteInt32(Int32)
Writes data of type System.
Declaration
public void WriteInt32(int value)
Parameters
System.
|
WriteInt64(Int64)
Writes data of type System.
Declaration
public void WriteInt64(long value)
Parameters
System.
|
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.
Declaration
public void WriteSByte(sbyte value)
Parameters
System.
|
WriteSingle(Single)
Writes data of type System.
Declaration
public void WriteSingle(float value)
Parameters
System.
|
WriteString(String)
Writes data of type System.
Declaration
public void WriteString(string value)
Parameters
System.
|
WriteUInt16(UInt16)
Writes data of type System.
Declaration
public void WriteUInt16(ushort value)
Parameters
System.
|
WriteUInt32(UInt32)
Writes data of type System.
Declaration
public void WriteUInt32(uint value)
Parameters
System.
|
WriteUInt64(UInt64)
Writes data of type System.
Declaration
public void WriteUInt64(ulong value)
Parameters
System.
|
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
|