• 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 Reader

Fast deserializer for network messages.

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

Constructors

Reader(ArraySegment<Byte>)

Create a new reader from the provided array segment.

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

Array segment to read from.

Reader(Byte[], Int32, Int32)

Create a new reader from the provided array segment.

Declaration
public Reader(byte[] array, int offset, int count)
Parameters
Type Name Description
System.Byte[] array

Array to read from.

System.Int32 offset

Offset in the array to start reading from.

System.Int32 count

Number of bytes to read.

Fields

First

Index of the first byte that is included in the message.

Declaration
public readonly int First
Field Value
Type Description
System.Int32

Last

Index of the last byte that is not included in the message.

Declaration
public readonly int Last
Field Value
Type Description
System.Int32

Properties

Available

Number of bytes still available to be read or 0 if the reader has been disposed.

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

Buffer

Internal buffer that contains the serialized message or null if the reader has been disposed.

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

Disposed

True if reader has been disposed.

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

Position

Current position in the internal buffer or 0 if the reader has been disposed.

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

Methods

CheckAvailableSpace(Int32)

Check if message has enough bytes left, throw exception if not.

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

Length to check for.

Dispose()

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

Declaration
public void Dispose()

ReadBoolean()

Read a single boolean (1 byte).

Declaration
public bool ReadBoolean()
Returns
Type Description
System.Boolean

Boolean value.

ReadBoolean(out Boolean, out Boolean, out Boolean, out Boolean, out Boolean, out Boolean, out Boolean, out Boolean)

Read 8 booleans (1 byte).

Declaration
public void ReadBoolean(out bool v0, out bool v1, out bool v2, out bool v3, out bool v4, out bool v5, out bool v6, out 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.

ReadByte()

Read byte (1 byte).

Declaration
public byte ReadByte()
Returns
Type Description
System.Byte

Byte value.

ReadBytes(Byte[], Int32, Int32)

Read into an array segment.

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

Array to read to.

System.Int32 offset

Array offset to read to.

System.Int32 count

Number of bytes to read.

ReadChar()

Read a single character (2 bytes).

Declaration
public char ReadChar()
Returns
Type Description
System.Char

Character value.

ReadDecimal()

Read decimal (16 bytes).

Declaration
public decimal ReadDecimal()
Returns
Type Description
System.Decimal

Decimal value.

ReadDouble()

Read double (8 bytes).

Declaration
public double ReadDouble()
Returns
Type Description
System.Double

Double value.

ReadEnum<T>()

Read enum (1, 2 or 4 bytes).

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

Declaration
public T ReadEnum<T>()
    where T : struct, IConvertible
Returns
Type Description
T

Enum value.

Type Parameters
Name Description
T

Enum type.

ReadInt16()

Read short (2 bytes).

Declaration
public short ReadInt16()
Returns
Type Description
System.Int16

Short value.

ReadInt32()

Read integer (4 bytes).

Declaration
public int ReadInt32()
Returns
Type Description
System.Int32

Integer value.

ReadInt64()

Read long integer (8 bytes).

Declaration
public long ReadInt64()
Returns
Type Description
System.Int64

Long integer value.

ReadSByte()

Read signed byte (1 byte).

Declaration
public sbyte ReadSByte()
Returns
Type Description
System.SByte

Signed byte value.

ReadSingle()

Read float (4 bytes).

Declaration
public float ReadSingle()
Returns
Type Description
System.Single

Float value.

ReadString()

Read 4 bytes length, then UTF8 encoded string.

Declaration
public string ReadString()
Returns
Type Description
System.String

String value or null if length is negative.

ReadUInt16()

Read unsigned short (2 bytes).

Declaration
public ushort ReadUInt16()
Returns
Type Description
System.UInt16

Unsigned short value.

ReadUInt32()

Read unsigned integer (4 bytes).

Declaration
public uint ReadUInt32()
Returns
Type Description
System.UInt32

Unsigned integer value.

ReadUInt64()

Read unsigned long integer (8 bytes).

Declaration
public ulong ReadUInt64()
Returns
Type Description
System.UInt64

Unsigned long integer value.

Reset(Int32)

Manually set the read position.

Declaration
public void Reset(int position)
Parameters
Type Name Description
System.Int32 position

Position to set.

Skip(Int32)

Advance the read position without reading anything.

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

Number of bytes to skip for.

Back to top Generated by DocFX