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(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> |
|
GetByteBuffer()
Returns the buffer as bytes. This does not trim excessive bytes.
Declaration
public byte[] GetByteBuffer()
Returns
Type |
Description |
System.Byte[] |
|
GetByteBufferAllocated()
Returns the buffer as bytes and allocates into a new array.
Declaration
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.
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
Returns
Type |
Description |
System.Byte |
|
ReadBytes(ref Byte[], Int32)
Read bytes from position into target.
Declaration
public void ReadBytes(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.
|
ReadBytesAllocated(Int32)
Creates a new byte array and reads bytes into it.
Declaration
public byte[] ReadBytesAllocated(int count)
Parameters
Type |
Name |
Description |
System.Int32 |
count |
|
Returns
Type |
Description |
System.Byte[] |
|
ReadBytesAndSize(ref Byte[])
Reads bytes and size and copies results into target. Returns UNSET if null was written.
Declaration
public int ReadBytesAndSize(ref byte[] target)
Parameters
Type |
Name |
Description |
System.Byte[] |
target |
|
Returns
Type |
Description |
System.Int32 |
Bytes read.
|
ReadBytesAndSizeAllocated()
Creates a byte array and reads bytes and size into it.
Declaration
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(AutoPackType)
Declaration
public Color ReadColor(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
UnityEngine.Color |
|
ReadColor32()
Declaration
public Color32 ReadColor32()
Returns
Type |
Description |
UnityEngine.Color32 |
|
ReadDateTime()
Declaration
public DateTime ReadDateTime()
Returns
Type |
Description |
System.DateTime |
|
ReadDecimal()
Declaration
public decimal ReadDecimal()
Returns
Type |
Description |
System.Decimal |
|
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 |
|
ReadGameObject()
Declaration
public GameObject ReadGameObject()
Returns
Type |
Description |
UnityEngine.GameObject |
|
ReadGuid()
Declaration
Returns
Type |
Description |
System.Guid |
|
ReadInt16()
Declaration
Returns
Type |
Description |
System.Int16 |
|
ReadInt32(AutoPackType)
Declaration
public int ReadInt32(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
System.Int32 |
|
ReadInt64(AutoPackType)
Declaration
public long ReadInt64(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
System.Int64 |
|
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 |
|
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
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 |
|
ReadPackedWhole()
Reads a packed whole number.
Declaration
public ulong ReadPackedWhole()
Returns
Type |
Description |
System.UInt64 |
|
ReadPlane()
Declaration
Returns
Type |
Description |
UnityEngine.Plane |
|
ReadQuaternion(AutoPackType)
Declaration
public Quaternion ReadQuaternion(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
UnityEngine.Quaternion |
|
ReadRay()
Declaration
Returns
Type |
Description |
UnityEngine.Ray |
|
ReadRay2D()
Declaration
Returns
Type |
Description |
UnityEngine.Ray2D |
|
ReadRect()
Declaration
Returns
Type |
Description |
UnityEngine.Rect |
|
ReadSByte()
Declaration
Returns
Type |
Description |
System.SByte |
|
ReadSingle(AutoPackType)
Declaration
public float ReadSingle(AutoPackType packType = AutoPackType.Unpacked)
Parameters
Returns
Type |
Description |
System.Single |
|
ReadString()
Declaration
public string ReadString()
Returns
Type |
Description |
System.String |
|
ReadTickUnpacked()
Reads a tick without packing.
Declaration
public uint ReadTickUnpacked()
Returns
Type |
Description |
System.UInt32 |
|
Declaration
public Transform ReadTransform()
Returns
Type |
Description |
UnityEngine.Transform |
|
ReadUInt16()
Declaration
public ushort ReadUInt16()
Returns
Type |
Description |
System.UInt16 |
|
ReadUInt32(AutoPackType)
Declaration
public uint ReadUInt32(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
System.UInt32 |
|
ReadUInt64(AutoPackType)
Declaration
public ulong ReadUInt64(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
System.UInt64 |
|
ReadVector2()
Declaration
public Vector2 ReadVector2()
Returns
Type |
Description |
UnityEngine.Vector2 |
|
ReadVector2Int(AutoPackType)
Declaration
public Vector2Int ReadVector2Int(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
UnityEngine.Vector2Int |
|
ReadVector3()
Declaration
public Vector3 ReadVector3()
Returns
Type |
Description |
UnityEngine.Vector3 |
|
ReadVector3Int(AutoPackType)
Declaration
public Vector3Int ReadVector3Int(AutoPackType packType = AutoPackType.Packed)
Parameters
Returns
Type |
Description |
UnityEngine.Vector3Int |
|
ReadVector4()
Declaration
public Vector4 ReadVector4()
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()
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