public static Version Deserialize(IInOctetStream stream)
        {
            var major = stream.ReadUint16();
            var minor = stream.ReadUint16();
            var patch = stream.ReadUint16();

            var prerelease = StringDeserializer.Deserialize(stream);

            return(new Version(major, minor, patch, prerelease));
        }
Example #2
0
        public static ConnectResponse Deserialize(IInOctetStream stream)
        {
            var myNonce      = stream.ReadUint32();
            var serverNonce  = stream.ReadUint32();
            var connectionId = stream.ReadUint16();

            return(new ConnectResponse(myNonce, connectionId, serverNonce));
        }
Example #3
0
        void ReadHeader(IInOctetStream stream, byte mode, int packetOctetCount, long nowMs)
        {
            var sequence             = stream.ReadUint8();
            var assignedConnectionId = stream.ReadUint16();

            if (assignedConnectionId == 0)
            {
                ReadOOB(stream, nowMs);
            }
            else
            {
                if (assignedConnectionId == connectionId)
                {
                    var headerSequenceId = new SequenceId(sequence);

                    if (lastIncomingSequence.IsValidSuccessor(headerSequenceId))
                    {
                        var diff      = lastIncomingSequence.Distance(headerSequenceId);
                        var timeStamp = DateTime.UtcNow;
                        if (diff > 1)
                        {
                            inStatsCollector.PacketsDropped(timeStamp, diff - 1);
                        }
                        inStatsCollector.PacketReceived(timeStamp, packetOctetCount);
                        simpleIn.AddPacket(packetOctetCount);
                        lastIncomingSequence = headerSequenceId;

                        if (mode == OobMode)
                        {
                            ReadOOB(stream, nowMs);
                        }
                        else
                        {
                            ReadConnectionPacket(stream, nowMs);
                        }
                    }
                }
            }

            lastValidHeader = monotonicClock.NowMilliseconds();
        }