コード例 #1
0
        private async Task ReceiveLoop()
        {
            CancellationToken cancel = recv_cancel.Token;

            while (true)
            {
                cancel.ThrowIfCancellationRequested();

                try
                {
                    byte[] message = await ReceiveMessage(cancel).ConfigureAwait(false);

                    AgarPacket packet = AgarPacket.FromByteArray(message);

                    lock (in_packets_l)
                    {
                        in_packets.Enqueue(packet);
                    }

                    OnPacketReceived(packet);
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
            }
        }
コード例 #2
0
 internal void SendPacket(AgarPacket a)
 {
     lock (out_packets_l)
     {
         out_packets.Enqueue(a);
     }
     packet_sent.Set();
 }
コード例 #3
0
        private void OnPacketReceived(AgarPacket packet)
        {
            packet_received.Set(); // Signal any waiting threads

            if (PacketReceived != null)
            {
                PacketReceived(this, packet);
            }
        }
コード例 #4
0
        private void OnPacketReceived(AgarPacket packet)
        {
            packet_received.Set(); // Signal any waiting threads

            if (PacketReceived != null)
                PacketReceived(this, packet);
        }
コード例 #5
0
 internal void SendPacket(AgarPacket a)
 {
     lock (out_packets_l)
     {
         out_packets.Enqueue(a);
     }
     packet_sent.Set();
 }