예제 #1
0
        private async Task SendNackQueueAsync()
        {
            RaknetSession session    = this;
            var           queue      = session.OutgoingNackQueue;
            int           queueCount = queue.Count;

            if (queueCount == 0)
            {
                return;
            }

            var acks = new CustomNak();

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

                ConnectionInfo.NumberOfPlayers++;
                acks.naks.Add(ack);
            }

            if (acks.naks.Count > 0)
            {
                byte[] data = acks.Encode();
                await _packetSender.SendDataAsync(data, session.EndPoint);
            }
            //acks.PutPool();
        }
예제 #2
0
        private async Task SendNackQueueAsync()
        {
            var queue      = OutgoingNackQueue;
            int queueCount = queue.Count;

            if (queueCount == 0)
            {
                return;
            }

            var acks = CustomNak.CreateObject();

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

                acks.Naks.Add(ack);
            }

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

                Interlocked.Increment(ref ConnectionInfo.NakSent);
            }
            acks.PutPool();
        }