• Home
  • Tutorials
  • API Documentation
  • Asset Store
Show / Hide Table of Contents
  • SuperNet.Netcode.Compress
    • CompressorDeflate
    • CompressorLZF
    • ICompressor
  • SuperNet.Netcode.Crypto
    • CryptoAES
    • CryptoECDH
    • CryptoRandom
    • CryptoRSA
    • Curve25519
    • ICryptoAuthenticator
    • ICryptoEncryptor
    • ICryptoExchanger
    • ICryptoRandom
  • SuperNet.Netcode.Transport
    • ConnectionRequest
    • DisconnectReason
    • Host
    • HostConfig
    • HostEvents
    • HostStatistics
    • HostTimespan
    • HostTimestamp
    • IHostListener
    • IMessage
    • IMessageListener
    • IPeerListener
    • MessageEvents
    • MessageReceived
    • MessageSent
    • Peer
    • PeerConfig
    • PeerEvents
    • PeerStatistics
  • SuperNet.Netcode.Util
    • Allocator
    • ArrayPool<T>
    • CRC32
    • IPComparer
    • IPResolver
    • IWritable
    • ObjectPool<T>
    • Reader
    • Serializer
    • Writer
  • SuperNet.Unity.Components
    • INetworkAuthoritative
    • INetworkRegisterable
    • INetworkRollbackable
    • NetworkAnimation
    • NetworkAnimator
    • NetworkAuthority
    • NetworkPrefab
    • NetworkRegistrar
    • NetworkSpawner
    • NetworkSyncModeMethod
    • NetworkSyncModeVector2
    • NetworkSyncModeVector3
    • NetworkTransform
  • SuperNet.Unity.Core
    • NetworkComponent
    • NetworkHost
    • NetworkIdentity
    • NetworkIdentityExtensions
    • NetworkManager
  • SuperNet.Unity.Editor
    • NetworkAuthorityEditor
    • NetworkHostEditor
    • NetworkHostEditor.BandwithUnit
    • NetworkIdentityDrawer
    • NetworkManagerEditor
    • NetworkPrefabEditor
    • NetworkSpawnerEditor

Class Writer

Fast serializer for network messages.

Inheritance
System.Object
Writer
Namespace: SuperNet.Netcode.Util
Assembly: cs.temp.dll.dll
Syntax
public class Writer : IDisposable

Constructors

Writer(Allocator, Int32)

Allocate a new buffer and create a writer for it. The buffer is automatically resized by the allocator.

Declaration
public Writer(Allocator allocator, int position)
Parameters
Type Name Description
Allocator allocator

Allocator to use for the internal buffer.

System.Int32 position

Initial position in the internal buffer.

Properties

Buffer

Internal buffer to write to or null if the writer has been disposed.

Declaration
public byte[] Buffer { get; }
Property Value
Type Description
System.Byte[]

Disposed

True if writer has been disposed.

Declaration
public bool Disposed { get; }
Property Value
Type Description
System.Boolean

Position

Current write position within the internal buffer or 0 if the writer has been disposed.

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

Methods

Dispose()

Invalidate the underlying buffer when it gets used for something else. Calling this causes all future write operation to fail.

Declaration
public void Dispose()

Skip(Int32)

Advance the write position without writing anything.

Declaration
public void Skip(int length)
Parameters
Type Name Description
System.Int32 length

Number of bytes to skip for.

Write(Boolean)

Write a single boolean value (1 byte) to the writer.

Declaration
public void Write(bool value)
Parameters
Type Name Description
System.Boolean value

Boolean to write.

Write(Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean)

Write 8 boolean values (1 byte) to the writer.

Declaration
public void Write(bool v0, bool v1, bool v2, bool v3, bool v4, bool v5, bool v6, bool v7)
Parameters
Type Name Description
System.Boolean v0

First boolean value.

System.Boolean v1

Second boolean value.

System.Boolean v2

Third boolean value.

System.Boolean v3

Fourth boolean value.

System.Boolean v4

Fifth boolean value.

System.Boolean v5

Sixth boolean value.

System.Boolean v6

Seventh boolean value.

System.Boolean v7

Eighth boolean value.

Write(Byte)

Write a single byte (1 byte) to the writer.

Declaration
public void Write(byte value)
Parameters
Type Name Description
System.Byte value

Byte to write.

Write(Char)

Write a single character (2 bytes) to the writer.

Declaration
public void Write(char value)
Parameters
Type Name Description
System.Char value

Character to write.

Write(Decimal)

Write a decimal (16 bytes) to the writer.

Declaration
public void Write(decimal value)
Parameters
Type Name Description
System.Decimal value

Decimal to write.

Write(Double)

Write a double (8 bytes) to the writer.

Declaration
public void Write(double value)
Parameters
Type Name Description
System.Double value

Double to write.

Write(Int16)

Write a short (2 bytes) to the writer.

Declaration
public void Write(short value)
Parameters
Type Name Description
System.Int16 value

Short to write.

Write(Int32)

Write an integer (4 bytes) to the writer.

Declaration
public void Write(int value)
Parameters
Type Name Description
System.Int32 value

Integer to write.

Write(Int64)

Write a long (8 bytes) to the writer.

Declaration
public void Write(long value)
Parameters
Type Name Description
System.Int64 value

Long to write.

Write(SByte)

Write a signed byte (1 byte) to the writer.

Declaration
public void Write(sbyte value)
Parameters
Type Name Description
System.SByte value

Signed byte to write.

Write(Single)

Write a float (4 bytes) to the writer.

Declaration
public void Write(float value)
Parameters
Type Name Description
System.Single value

Float to write.

Write(String)

Write 4 bytes for length, then UTF8 encoded string.

Declaration
public void Write(string value)
Parameters
Type Name Description
System.String value

String to write.

Write(UInt16)

Write an unsigned short (2 bytes) to the writer.

Declaration
public void Write(ushort value)
Parameters
Type Name Description
System.UInt16 value

Unsigned short to write.

Write(UInt32)

Write an unsigned integer (4 bytes) to the writer.

Declaration
public void Write(uint value)
Parameters
Type Name Description
System.UInt32 value

Unsigned integer to write.

Write(UInt64)

Write an unsigned long (8 bytes) to the writer.

Declaration
public void Write(ulong value)
Parameters
Type Name Description
System.UInt64 value

Unsigned long to write.

WriteBytes(ArraySegment<Byte>)

Copy a segment of bytes to the writer.

Declaration
public void WriteBytes(ArraySegment<byte> segment)
Parameters
Type Name Description
ArraySegment<System.Byte> segment

Segment to copy

WriteBytes(Byte[])

Copy an entire buffer to the writer.

Declaration
public void WriteBytes(byte[] buffer)
Parameters
Type Name Description
System.Byte[] buffer

Buffer to copy.

WriteBytes(Byte[], Int32, Int32)

Copy a segment of bytes to the writer.

Declaration
public void WriteBytes(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

Buffer to copy from.

System.Int32 offset

Offset within the provided buffer.

System.Int32 count

Number of bytes to copy.

WriteEnum<T>(T)

Write an enum (1, 2 or 4 bytes) to the writer.

Number of bytes written is dependant on the underlying type enum is backed by.

Declaration
public void WriteEnum<T>(T value)
    where T : struct, IConvertible
Parameters
Type Name Description
T value

Enum value.

Type Parameters
Name Description
T

Enum type.

Back to top Generated by DocFX