Ejemplo n.º 1
0
        public bool Acknowledge(Int24 datagramSequenceNumber)
        {
            var sequence = datagramSequenceNumber.IntValue();

            OutgoingAckQueue.Enqueue(sequence);

            var lastDatagram = Interlocked.Read(ref _lastDatagramSequenceNumber);

            if (sequence > lastDatagram)
            {
                var last    = Interlocked.CompareExchange(ref _lastDatagramSequenceNumber, sequence, lastDatagram);
                var skipped = sequence - last - 1;

                if (skipped > 0)
                {
                    for (long i = last; i < sequence; i++)
                    {
                        if (_nacked.TryAdd((int)i))
                        {
                            OutgoingNackQueue.Enqueue((int)i);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void EnqueueAck(IPEndPoint senderEndpoint, Int24 sequenceNumber)
        {
            _numberOfAckSent++;

            if (_playerSessions.ContainsKey(senderEndpoint))
            {
                var session = _playerSessions[senderEndpoint];
                session.PlayerAckQueue.Enqueue(sequenceNumber.IntValue());
            }
        }
Ejemplo n.º 3
0
        public void Acknowledge(Int24 datagramSequenceNumber)
        {
            var integerValue = datagramSequenceNumber.IntValue();
            var last         = Interlocked.Exchange(ref _lastDatagramSequenceNumber, integerValue);
            var skipped      = last - integerValue - 1;

            if (skipped > 0)
            {
                for (long i = last + 1; i < integerValue - 1; i++)
                {
                    OutgoingNackQueue.Enqueue((int)i);
                }
            }

            OutgoingAckQueue.Enqueue(datagramSequenceNumber);
        }