Exemplo n.º 1
0
        private async Task SendAckQueueAsync()
        {
            RakSession session    = this;
            var        queue      = session.OutgoingAckQueue;
            int        queueCount = queue.Count;

            if (queueCount == 0)
            {
                return;
            }

            var acks = Acks.CreateObject();

            for (int i = 0; i < queueCount; i++)
            {
                if (!queue.TryDequeue(out int ack))
                {
                    break;
                }

                Interlocked.Increment(ref ConnectionInfo.NumberOfAckSent);
                acks.acks.Add(ack);
            }

            if (acks.acks.Count > 0)
            {
                byte[] data = acks.Encode();
                await _packetSender.SendDataAsync(data, session.EndPoint);
            }

            acks.PutPool();
        }