Ejemplo n.º 1
0
        public void Deserialize(BitStream stream)
        {
            MessageNumber = stream.ReadUInt();

            Reliability = (PacketReliability)stream.ReadBits(3)[0];

            if (Reliability == PacketReliability.UnreliableSequenced ||
                Reliability == PacketReliability.ReliableSequenced ||
                Reliability == PacketReliability.ReliableOrdered)
            {
                OrderingChannel = stream.ReadBits(5)[0];
                OrderingIndex   = stream.ReadUInt();
            }

            SplitPacket = stream.ReadBit();

            if (SplitPacket)
            {
                SplitPacketId    = stream.ReadUShort();
                SplitPacketIndex = stream.ReadCompressedUInt();
                SplitPacketCount = stream.ReadCompressedUInt();
            }

            var length = stream.ReadCompressedUShort();

            stream.AlignRead();

            Data = stream.Read(BitStream.BitsToBytes(length));
        }
Ejemplo n.º 2
0
        public static int GetHeaderLength(PacketReliability reliability, bool splitPacket)
        {
            var length = 52;

            if (reliability == PacketReliability.UnreliableSequenced ||
                reliability == PacketReliability.ReliableOrdered)
            {
                length += 37;
            }

            if (splitPacket)
            {
                length += 80;
            }

            return(BitStream.BitsToBytes(length));
        }