NetWriter

csharp
public sealed class NetWriter

Namespace NodeWorld.Flux.

What a script writes to the network: its synced state (OnSerialize) or the arguments of a network event. Read back in the same order with NetReader. Little-endian; strings in UTF-16 with their length.

Constructors

NetWriter

csharp
public NetWriter(int capacity = 64)

An empty writer; capacity is the size it starts with (16 bytes at least): it grows as you write.

Properties

Length

csharp
public int Length { get; }

Bytes written so far.

Methods

Clear

csharp
public void Clear()

Forgets what was written, to write again from the start.

Write

csharp
public void Write(byte value)

Writes a byte (ReadByte).

csharp
public void Write(bool value)

Writes a bool as one byte (ReadBool).

csharp
public void Write(int value)

Writes an int in 4 bytes (ReadInt).

csharp
public void Write(uint value)

Writes a uint in 4 bytes (ReadUInt).

csharp
public void Write(long value)

Writes a long in 8 bytes (ReadLong).

csharp
public void Write(float value)

Writes a float in 4 bytes (ReadFloat).

csharp
public void Write(double value)

Writes a double in 8 bytes (ReadDouble).

csharp
public void Write(string value)

Writes a string: its length, then 2 bytes per character; null is kept as null (ReadString).

csharp
public void Write(Vector2 value)

Writes a Vector2: x, y (ReadVector2).

csharp
public void Write(Vector3 value)

Writes a Vector3: x, y, z (ReadVector3).

csharp
public void Write(Vector4 value)

Writes a Vector4: x, y, z, w (ReadVector4).

csharp
public void Write(Quaternion value)

Writes a Quaternion: x, y, z, w (ReadQuaternion).

csharp
public void Write(Color value)

Writes a Color: r, g, b, a (ReadColor).

csharp
public void Write(int[] values)

Writes an int array: its length, then each value; null is kept as null (ReadIntArray).

csharp
public void Write(float[] values)

Writes a float array: its length, then each value; null is kept as null (ReadFloatArray).

csharp
public void Write(bool[] values)

Writes a bool array: its length, then each value; null is kept as null (ReadBoolArray).

csharp
public void Write(string[] values)

Writes a string array: its length, then each string; null is kept as null (ReadStringArray).

csharp
public void Write(byte[] values)

Writes a byte array: its length, then its bytes; null is kept as null (ReadBytes).

csharp
public void Write(Vector3[] values)

Writes a Vector3 array: its length, then each vector; null is kept as null (ReadVector3Array).