Class Reader
Reads data from a buffer.
Inheritance
System.Object
Reader
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: FishNet.Runtime.dll
Syntax
Constructors
Reader()
Declaration
Reader(ArraySegment<Byte>, NetworkManager, NetworkConnection, Reader.DataSource)
Declaration
public Reader(ArraySegment<byte> segment, NetworkManager networkManager, NetworkConnection networkConnection = null, Reader.DataSource source = Reader.DataSource.Unset)
Parameters
Reader(Byte[], NetworkManager, NetworkConnection, Reader.DataSource)
Declaration
public Reader(byte[] bytes, NetworkManager networkManager, NetworkConnection networkConnection = null, Reader.DataSource source = Reader.DataSource.Unset)
Parameters
Fields
NetworkManager
NetworkManager for this reader. Used to lookup objects.
Declaration
public NetworkManager NetworkManager
Field Value
Position
Position for the next read.
Declaration
Field Value
Type |
Description |
System.Int32 |
|
Source
Which part of the network the data came from.
Declaration
public Reader.DataSource Source
Field Value
Properties
Capacity
Declaration
public int Capacity { get; }
Property Value
Type |
Description |
System.Int32 |
|
Length
Total number of bytes available within the buffer.
Declaration
public int Length { get; }
Property Value
Type |
Description |
System.Int32 |
|
NetworkConnection
NetworkConnection that this data came from.
Value may not always be set.
Declaration
public NetworkConnection NetworkConnection { get; }
Property Value
Offset
Offset within the buffer when the reader was created.
Declaration
public int Offset { get; }
Property Value
Type |
Description |
System.Int32 |
|
Remaining
Bytes remaining to be read. This value is Length - Position.
Declaration
public int Remaining { get; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
BlockCopy(ref Byte[], Int32, Int32)
BlockCopies data from the reader to target and advances reader.
Declaration
public void BlockCopy(ref byte[] target, int targetOffset, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
target |
|
System.Int32 |
targetOffset |
|
System.Int32 |
count |
|
Clear()
Clears remaining bytes to be read.
Declaration
GetArraySegmentBuffer()
Returns the buffer as an ArraySegment.
Declaration
public ArraySegment<byte> GetArraySegmentBuffer()
Returns
Type |
Description |
System.ArraySegment<System.Byte> |
|
GetBuffer()
Returns the buffer as bytes. This does not trim excessive bytes.
Declaration
public byte[] GetBuffer()
Returns
Type |
Description |
System.Byte[] |
|
GetBufferAllocated()
Returns the buffer as bytes and allocates into a new array.
Declaration
[Obsolete("Use GetBufferAllocated().")]
public byte[] GetBufferAllocated()
Returns
Type |
Description |
System.Byte[] |
|
GetByteBuffer()
Declaration
[Obsolete("Use GetBuffer.")]
public byte[] GetByteBuffer()
Returns
Type |
Description |
System.Byte[] |
|
GetByteBufferAllocated()
Declaration
[Obsolete("Use GetBufferAllocated().")]
public byte[] GetByteBufferAllocated()
Returns
Type |
Description |
System.Byte[] |
|
GetRemainingData()
Returns remaining data as an ArraySegment.
Declaration
public ArraySegment<byte> GetRemainingData()
Returns
Type |
Description |
System.ArraySegment<System.Byte> |
|
Read<T>()
Reads any supported type as packed.
Declaration
Returns
Type Parameters
ReadArray<T>(ref T[])
Reads into collection and returns amount read.
Declaration
public int ReadArray<T>(ref T[] collection)
Parameters
Type |
Name |
Description |
T[] |
collection |
|
Returns
Type |
Description |
System.Int32 |
|
Type Parameters
ReadArrayAllocated<T>()
Declaration
public T[] ReadArrayAllocated<T>()
Returns
Type Parameters
ReadArraySegment(Int32)
Creates an ArraySegment by reading a number of bytes from position.
Declaration
public ArraySegment<byte> ReadArraySegment(int count)
Parameters
Type |
Name |
Description |
System.Int32 |
count |
|
Returns
Type |
Description |
System.ArraySegment<System.Byte> |
|
ReadArraySegmentAndSize()
Reads bytes and size and returns as an ArraySegment.
Declaration
public ArraySegment<byte> ReadArraySegmentAndSize()
Returns
Type |
Description |
System.ArraySegment<System.Byte> |
|
ReadBoolean()
Declaration
public bool ReadBoolean()
Returns
Type |
Description |
System.Boolean |
|
ReadByte()
Declaration
[Obsolete("Use ReadUInt8Unpacked.")]
public byte ReadByte()
Returns
Type |
Description |
System.Byte |
|
ReadBytes(ref Byte[], Int32)
Declaration
[Obsolete("Use ReadUInt8Array.")]
public void ReadBytes(ref byte[] buffer, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
buffer |
|
System.Int32 |
count |
|
ReadBytesAllocated(Int32)
Declaration
[Obsolete("Use ReadUInt8ArrayAllocated.")]
public byte[] ReadBytesAllocated(int count)
Parameters
Type |
Name |
Description |
System.Int32 |
count |
|
Returns
Type |
Description |
System.Byte[] |
|
ReadBytesAndSize(ref Byte[])
Declaration
[Obsolete("Use ReadUInt8ArrayAndSize.")]
public int ReadBytesAndSize(ref byte[] target)
Parameters
Type |
Name |
Description |
System.Byte[] |
target |
|
Returns
Type |
Description |
System.Int32 |
|
ReadBytesAndSizeAllocated()
Declaration
[Obsolete("Use ReadUInt8ArrayAndSizeAllocated.")]
public byte[] ReadBytesAndSizeAllocated()
Returns
Type |
Description |
System.Byte[] |
|
ReadChannel()
Reads a transport channel.
Declaration
public Channel ReadChannel()
Returns
ReadChar()
Declaration
Returns
Type |
Description |
System.Char |
|
ReadColor()
Declaration
Returns
Type |
Description |
UnityEngine.Color |
|
ReadColor32()
Declaration
public Color32 ReadColor32()
Returns
Type |
Description |
UnityEngine.Color32 |
|
ReadColorUnpacked()
Declaration
public Color ReadColorUnpacked()
Returns
Type |
Description |
UnityEngine.Color |
|
ReadDateTime()
Declaration
public DateTime ReadDateTime()
Returns
Type |
Description |
System.DateTime |
|
ReadDecimal()
Declaration
public decimal ReadDecimal()
Returns
Type |
Description |
System.Decimal |
|
ReadDecimalUnpacked()
Declaration
public decimal ReadDecimalUnpacked()
Returns
Type |
Description |
System.Decimal |
|
ReadDelta<T>(T)
Reads a delta of any time.
Declaration
public T ReadDelta<T>(T prev)
Parameters
Type |
Name |
Description |
T |
prev |
|
Returns
Type Parameters
ReadDeltaBoolean(Boolean)
Declaration
public bool ReadDeltaBoolean(bool valueA)
Parameters
Type |
Name |
Description |
System.Boolean |
valueA |
|
Returns
Type |
Description |
System.Boolean |
|
ReadDeltaDecimal(Decimal)
Reads a difference, appending it onto a value.
Declaration
public decimal ReadDeltaDecimal(decimal valueA)
Parameters
Type |
Name |
Description |
System.Decimal |
valueA |
|
Returns
Type |
Description |
System.Decimal |
|
ReadDeltaInt16(Int16)
Reads a difference, appending it onto a value.
Declaration
public short ReadDeltaInt16(short valueA)
Parameters
Type |
Name |
Description |
System.Int16 |
valueA |
|
Returns
Type |
Description |
System.Int16 |
|
ReadDeltaInt32(Int32)
Reads a difference, appending it onto a value.
Declaration
public int ReadDeltaInt32(int valueA)
Parameters
Type |
Name |
Description |
System.Int32 |
valueA |
|
Returns
Type |
Description |
System.Int32 |
|
ReadDeltaInt64(Int64)
Reads a difference, appending it onto a value.
Declaration
public long ReadDeltaInt64(long valueA)
Parameters
Type |
Name |
Description |
System.Int64 |
valueA |
|
Returns
Type |
Description |
System.Int64 |
|
ReadDeltaInt8(SByte)
Reads a difference, appending it onto a value.
Declaration
public sbyte ReadDeltaInt8(sbyte valueA)
Parameters
Type |
Name |
Description |
System.SByte |
valueA |
|
Returns
Type |
Description |
System.SByte |
|
ReadDeltaQuaternion(Quaternion)
Reads a difference, appending it onto a value.
(not really for Quaternion).
Declaration
public Quaternion ReadDeltaQuaternion(Quaternion valueA)
Parameters
Type |
Name |
Description |
UnityEngine.Quaternion |
valueA |
|
Returns
Type |
Description |
UnityEngine.Quaternion |
|
ReadDeltaUInt16(UInt16)
Reads a difference, appending it onto a value.
Declaration
public ushort ReadDeltaUInt16(ushort valueA)
Parameters
Type |
Name |
Description |
System.UInt16 |
valueA |
|
Returns
Type |
Description |
System.UInt16 |
|
ReadDeltaUInt32(UInt32)
Reads a difference, appending it onto a value.
Declaration
public uint ReadDeltaUInt32(uint valueA)
Parameters
Type |
Name |
Description |
System.UInt32 |
valueA |
|
Returns
Type |
Description |
System.UInt32 |
|
ReadDeltaUInt64(UInt64)
Reads a difference, appending it onto a value.
Declaration
public ulong ReadDeltaUInt64(ulong valueA)
Parameters
Type |
Name |
Description |
System.UInt64 |
valueA |
|
Returns
Type |
Description |
System.UInt64 |
|
ReadDeltaUInt8(Byte)
Reads a difference, appending it onto a value.
Declaration
public byte ReadDeltaUInt8(byte valueA)
Parameters
Type |
Name |
Description |
System.Byte |
valueA |
|
Returns
Type |
Description |
System.Byte |
|
ReadDeltaVector2(Vector2)
Reads a difference, appending it onto a value.
Declaration
public Vector2 ReadDeltaVector2(Vector2 valueA)
Parameters
Type |
Name |
Description |
UnityEngine.Vector2 |
valueA |
|
Returns
Type |
Description |
UnityEngine.Vector2 |
|
ReadDeltaVector3(Vector3)
Reads a difference, appending it onto a value.
Declaration
public Vector3 ReadDeltaVector3(Vector3 valueA)
Parameters
Type |
Name |
Description |
UnityEngine.Vector3 |
valueA |
|
Returns
Type |
Description |
UnityEngine.Vector3 |
|
ReadDictionaryAllocated<TKey, TValue>()
Declaration
public Dictionary<TKey, TValue> ReadDictionaryAllocated<TKey, TValue>()
Returns
Type |
Description |
System.Collections.Generic.Dictionary<TKey, TValue> |
|
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
ReadDouble()
Declaration
public double ReadDouble()
Returns
Type |
Description |
System.Double |
|
ReadDoubleUnpacked()
Declaration
public double ReadDoubleUnpacked()
Returns
Type |
Description |
System.Double |
|
ReadGameObject()
Declaration
public GameObject ReadGameObject()
Returns
Type |
Description |
UnityEngine.GameObject |
|
ReadGuid()
Declaration
Returns
Type |
Description |
System.Guid |
|
ReadInt16()
Declaration
Returns
Type |
Description |
System.Int16 |
|
ReadInt16Unpacked()
Declaration
public short ReadInt16Unpacked()
Returns
Type |
Description |
System.Int16 |
|
ReadInt32()
Declaration
Returns
Type |
Description |
System.Int32 |
|
ReadInt32Unpacked()
Declaration
public int ReadInt32Unpacked()
Returns
Type |
Description |
System.Int32 |
|
ReadInt64()
Declaration
Returns
Type |
Description |
System.Int64 |
|
ReadInt64Unpacked()
Declaration
public long ReadInt64Unpacked()
Returns
Type |
Description |
System.Int64 |
|
ReadInt8Unpacked()
Declaration
public sbyte ReadInt8Unpacked()
Returns
Type |
Description |
System.SByte |
|
ReadLayerMask()
Declaration
public LayerMask ReadLayerMask()
Returns
Type |
Description |
UnityEngine.LayerMask |
|
ReadList<T>(ref List<T>, Boolean)
Reads into collection and returns item count read.
Declaration
public int ReadList<T>(ref List<T> collection, bool allowNullification = false)
Parameters
Type |
Name |
Description |
System.Collections.Generic.List<T> |
collection |
|
System.Boolean |
allowNullification |
True to allow the referenced collection to be nullified when receiving a null collection read.
|
Returns
Type |
Description |
System.Int32 |
Number of values read into the collection. UNSET is returned if the collection were read as null.
|
Type Parameters
ReadListAllocated<T>()
Reads a list with allocations.
Declaration
public List<T> ReadListAllocated<T>()
Returns
Type |
Description |
System.Collections.Generic.List<T> |
|
Type Parameters
ReadMatrix4x4()
Declaration
public Matrix4x4 ReadMatrix4x4()
Returns
Type |
Description |
UnityEngine.Matrix4x4 |
|
ReadMatrix4x4Unpacked()
Declaration
public Matrix4x4 ReadMatrix4x4Unpacked()
Returns
Type |
Description |
UnityEngine.Matrix4x4 |
|
ReadNetworkBehaviour()
Reads a NetworkBehaviour.
Declaration
public NetworkBehaviour ReadNetworkBehaviour()
Returns
ReadNetworkBehaviour(out Int32, out Byte, HashSet<Int32>)
Reads a NetworkBehaviour.
Declaration
public NetworkBehaviour ReadNetworkBehaviour(out int objectId, out byte componentIndex, HashSet<int> readSpawningObjects = null)
Parameters
Type |
Name |
Description |
System.Int32 |
objectId |
|
System.Byte |
componentIndex |
|
System.Collections.Generic.HashSet<System.Int32> |
readSpawningObjects |
Objects which have been read to be spawned this tick, but may not have spawned yet.
|
Returns
ReadNetworkBehaviourId()
Reads a NetworkBehaviourId.
Declaration
public byte ReadNetworkBehaviourId()
Returns
Type |
Description |
System.Byte |
|
ReadNetworkConnection()
Reads a NetworkConnection.
Declaration
public NetworkConnection ReadNetworkConnection()
Returns
ReadNetworkConnectionId()
Reads the Id for a NetworkConnection.
Declaration
public int ReadNetworkConnectionId()
Returns
Type |
Description |
System.Int32 |
|
ReadNetworkObject()
Declaration
public NetworkObject ReadNetworkObject()
Returns
ReadNetworkObject(out Int32, HashSet<Int32>)
Declaration
public NetworkObject ReadNetworkObject(out int objectOrPrefabId, HashSet<int> readSpawningObjects = null)
Parameters
Type |
Name |
Description |
System.Int32 |
objectOrPrefabId |
|
System.Collections.Generic.HashSet<System.Int32> |
readSpawningObjects |
Objects which have been read to be spawned this tick, but may not have spawned yet.
|
Returns
ReadNetworkObjectId()
Reads a NetworkObjectId and nothing else.
Declaration
public int ReadNetworkObjectId()
Returns
Type |
Description |
System.Int32 |
|
ReadPlane()
Declaration
Returns
Type |
Description |
UnityEngine.Plane |
|
ReadPlaneUnpacked()
Declaration
public Plane ReadPlaneUnpacked()
Returns
Type |
Description |
UnityEngine.Plane |
|
ReadQuaternion32()
Declaration
public Quaternion ReadQuaternion32()
Returns
Type |
Description |
UnityEngine.Quaternion |
|
ReadQuaternion64()
Declaration
public Quaternion ReadQuaternion64()
Returns
Type |
Description |
UnityEngine.Quaternion |
|
ReadQuaternionUnpacked()
Declaration
public Quaternion ReadQuaternionUnpacked()
Returns
Type |
Description |
UnityEngine.Quaternion |
|
ReadRay()
Declaration
Returns
Type |
Description |
UnityEngine.Ray |
|
ReadRay2D()
Declaration
Returns
Type |
Description |
UnityEngine.Ray2D |
|
ReadRay2DUnpacked()
Declaration
public Ray2D ReadRay2DUnpacked()
Returns
Type |
Description |
UnityEngine.Ray2D |
|
ReadRayUnpacked()
Declaration
public Ray ReadRayUnpacked()
Returns
Type |
Description |
UnityEngine.Ray |
|
ReadRect()
Declaration
Returns
Type |
Description |
UnityEngine.Rect |
|
ReadRectUnpacked()
Declaration
public Rect ReadRectUnpacked()
Returns
Type |
Description |
UnityEngine.Rect |
|
ReadSByte()
Declaration
[Obsolete("Use ReadInt8Unpacked.")]
public sbyte ReadSByte()
Returns
Type |
Description |
System.SByte |
|
ReadSignedPackedWhole()
Reads a packed whole number and applies zigzag decoding.
Declaration
public long ReadSignedPackedWhole()
Returns
Type |
Description |
System.Int64 |
|
ReadSingle()
Declaration
public float ReadSingle()
Returns
Type |
Description |
System.Single |
|
ReadSingleUnpacked()
Declaration
public float ReadSingleUnpacked()
Returns
Type |
Description |
System.Single |
|
ReadString()
Declaration
public string ReadString()
Returns
Type |
Description |
System.String |
|
ReadSubStream()
Reads a substream. Start reading from it with StartReading method.
Declaration
public SubStream ReadSubStream()
Returns
ReadTickUnpacked()
Reads a tick without packing.
Declaration
public uint ReadTickUnpacked()
Returns
Type |
Description |
System.UInt32 |
|
Declaration
public Transform ReadTransform()
Returns
Type |
Description |
UnityEngine.Transform |
|
ReadUDeltaDecimal(Decimal)
Reads a difference, appending it onto a value.
Declaration
public decimal ReadUDeltaDecimal(decimal valueA)
Parameters
Type |
Name |
Description |
System.Decimal |
valueA |
|
Returns
Type |
Description |
System.Decimal |
|
ReadUDeltaDouble(Double)
Reads a difference, appending it onto a value.
Declaration
public double ReadUDeltaDouble(double valueA)
Parameters
Type |
Name |
Description |
System.Double |
valueA |
|
Returns
Type |
Description |
System.Double |
|
ReadUDeltaSingle(Single)
Reads a difference, appending it onto a value.
Declaration
public float ReadUDeltaSingle(float valueA)
Parameters
Type |
Name |
Description |
System.Single |
valueA |
|
Returns
Type |
Description |
System.Single |
|
ReadUInt16()
Declaration
public ushort ReadUInt16()
Returns
Type |
Description |
System.UInt16 |
|
ReadUInt16Unpacked()
Declaration
public ushort ReadUInt16Unpacked()
Returns
Type |
Description |
System.UInt16 |
|
ReadUInt32()
Declaration
Returns
Type |
Description |
System.UInt32 |
|
ReadUInt32Unpacked()
Declaration
public uint ReadUInt32Unpacked()
Returns
Type |
Description |
System.UInt32 |
|
ReadUInt64()
Declaration
public ulong ReadUInt64()
Returns
Type |
Description |
System.UInt64 |
|
ReadUInt64Unpacked()
Declaration
public ulong ReadUInt64Unpacked()
Returns
Type |
Description |
System.UInt64 |
|
ReadUInt8Array(ref Byte[], Int32)
Read bytes from position into target.
Declaration
public void ReadUInt8Array(ref byte[] buffer, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
buffer |
Buffer to read bytes into.
|
System.Int32 |
count |
Number of bytes to read.
|
ReadUInt8ArrayAllocated(Int32)
Creates a new byte array and reads bytes into it.
Declaration
public byte[] ReadUInt8ArrayAllocated(int count)
Parameters
Type |
Name |
Description |
System.Int32 |
count |
|
Returns
Type |
Description |
System.Byte[] |
|
ReadUInt8ArrayAndSize(ref Byte[])
Reads bytes and size and copies results into target. Returns UNSET if null was written.
Declaration
public int ReadUInt8ArrayAndSize(ref byte[] target)
Parameters
Type |
Name |
Description |
System.Byte[] |
target |
|
Returns
Type |
Description |
System.Int32 |
Bytes read.
|
ReadUInt8ArrayAndSizeAllocated()
Creates a byte array and reads bytes and size into it.
Declaration
public byte[] ReadUInt8ArrayAndSizeAllocated()
Returns
Type |
Description |
System.Byte[] |
|
ReadUInt8Unpacked()
Declaration
public byte ReadUInt8Unpacked()
Returns
Type |
Description |
System.Byte |
|
ReadUnsignedPackedWhole()
Reads a packed whole number.
Declaration
public ulong ReadUnsignedPackedWhole()
Returns
Type |
Description |
System.UInt64 |
|
ReadVector2()
Declaration
public Vector2 ReadVector2()
Returns
Type |
Description |
UnityEngine.Vector2 |
|
ReadVector2Int()
Declaration
public Vector2Int ReadVector2Int()
Returns
Type |
Description |
UnityEngine.Vector2Int |
|
ReadVector2IntUnpacked()
Declaration
public Vector2Int ReadVector2IntUnpacked()
Returns
Type |
Description |
UnityEngine.Vector2Int |
|
ReadVector2Unpacked()
Declaration
public Vector2 ReadVector2Unpacked()
Returns
Type |
Description |
UnityEngine.Vector2 |
|
ReadVector3()
Declaration
public Vector3 ReadVector3()
Returns
Type |
Description |
UnityEngine.Vector3 |
|
ReadVector3Int()
Declaration
public Vector3Int ReadVector3Int()
Returns
Type |
Description |
UnityEngine.Vector3Int |
|
ReadVector3IntUnpacked()
Declaration
public Vector3Int ReadVector3IntUnpacked()
Returns
Type |
Description |
UnityEngine.Vector3Int |
|
ReadVector3Unpacked()
Declaration
public Vector3 ReadVector3Unpacked()
Returns
Type |
Description |
UnityEngine.Vector3 |
|
ReadVector4()
Declaration
public Vector4 ReadVector4()
Returns
Type |
Description |
UnityEngine.Vector4 |
|
ReadVector4Unpacked()
Declaration
public Vector4 ReadVector4Unpacked()
Returns
Type |
Description |
UnityEngine.Vector4 |
|
RemainingToString()
Outputs reader to string.
Declaration
public string RemainingToString()
Returns
Type |
Description |
System.String |
|
Skip(Int32)
Skips a number of bytes in the reader.
Declaration
public void Skip(int value)
Parameters
Type |
Name |
Description |
System.Int32 |
value |
Number of bytes to skip.
|
ToString()
Outputs reader to string.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
ToString(Int32, Int32)
Outputs reader to string starting at an index.
Declaration
public string ToString(int offset, int length)
Parameters
Type |
Name |
Description |
System.Int32 |
offset |
|
System.Int32 |
length |
|
Returns
Type |
Description |
System.String |
|
WriteDeltaNetworkBehaviour(NetworkBehaviour)
Declaration
public NetworkBehaviour WriteDeltaNetworkBehaviour(NetworkBehaviour valueA)
Parameters
Returns
ZigZagDecode(UInt64)
ZigZag decode an integer. Move the sign bit back to the left.
Declaration
public ulong ZigZagDecode(ulong value)
Parameters
Type |
Name |
Description |
System.UInt64 |
value |
|
Returns
Type |
Description |
System.UInt64 |
|
Extension Methods