Skip to main content

Unity.Networking.Transport.Utilities.SequenceHelpers

Inheritance#

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Inherited Members#

Object.Equals(Object)

Object.Equals(Object, Object)

Object.GetHashCode()

Object.GetType()

Object.MemberwiseClone()

Object.ReferenceEquals(Object, Object)

Object.ToString()

Namespace: System.Dynamic.ExpandoObject#
Assembly: transport.dll#
Syntax#
public static class SequenceHelpers

AbsDistance(UInt16, UInt16)#

Calculate the difference between two sequence IDs, taking integer overflow/underflow into account. For example, both AbsDistance(65535, 0) and AbsDistance(0, 65535) will return 1, not 65535.

Declaration#

public static int AbsDistance(ushort lhs, ushort rhs)

Parameters#

TypeNameDescription
System.UInt16lhsThe first sequence ID. Compared against the second.
System.UInt16rhsThe second sequence ID. Compared against the first.

Returns#

TypeDescription
System.Int32An integer value equal to the distance between the sequence IDs.

BitMaskToString(UInt32)#

Converts a bitmask integer to a string representation of its binary expression, e.g. a mask value of 4 will return a string with the 3rd bit set: 00000000000000000000000000000100

Declaration#

public static string BitMaskToString(uint mask)

Parameters#

TypeNameDescription
System.UInt32maskThe bitmask in integer format.

Returns#

TypeDescription
System.StringA string that represents the bitmask.

GreaterThan16(UInt16, UInt16)#

Describes whether the non-wrapping difference between two sequenceIDs is less than 2^15 (or 0x8000, or 32768). (The "16" seems to be the 16th bit in a 16-bit integer.)

Declaration#

public static bool GreaterThan16(ushort lhs, ushort rhs)

Parameters#

TypeNameDescription
System.UInt16lhsThe first operand.
System.UInt16rhsThe second operand.

Returns#

TypeDescription
System.BooleanWhether or not the non-wrapping difference between the two operands is less than or equal to unsigned 0x7FFF.

IsNewer(UInt32, UInt32)#

This method was originally added in February 2019, but does not seem to be used anywhere currently. Its original context seems to have been intended for a very simple version of checking whether a packet's sequence ID was equal to or newer than the last received packet.

Declaration#

public static bool IsNewer(uint current, uint old)

Parameters#

TypeNameDescription
System.UInt32currentThe sequence ID of a newly-arrived packet to check
System.UInt32oldThe sequence ID of a previously received packet

Returns#

TypeDescription
System.Booleantrue if current is newer than old

LessThan16(UInt16, UInt16)#

Describes whether the non-absolute difference between two sequenceIDs is greater than or equal to 2^15 (or 0x8000, or 32768). (The "16" seems to be the 16th bit in a 16-bit integer.)

Declaration#

public static bool LessThan16(ushort lhs, ushort rhs)

Parameters#

TypeNameDescription
System.UInt16lhsThe first operand.
System.UInt16rhsThe second operand.

Returns#

TypeDescription
System.BooleanWhether or not the non-wrapping difference between the two operands is greater than unsigned 0x7FFF.

StalePacket(UInt16, UInt16, UInt16)#

Describes whether a packet is stale in the context of sequenced pipelines.

Declaration#

public static bool StalePacket(ushort sequence, ushort oldSequence, ushort windowSize)

Parameters#

TypeNameDescription
System.UInt16sequenceThe more recent sequence ID.
System.UInt16oldSequenceThe older sequence ID.
System.UInt16windowSizeThe window size

Returns#

TypeDescription
System.BooleanA boolean value containing the results of LessThan16(UInt16, UInt16) where lhs = sequence and rhs = oldSequence - windowSize.