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; } } }
internal void SendPacket(AgarPacket a) { lock (out_packets_l) { out_packets.Enqueue(a); } packet_sent.Set(); }
private void OnPacketReceived(AgarPacket packet) { packet_received.Set(); // Signal any waiting threads if (PacketReceived != null) { PacketReceived(this, packet); } }
private void OnPacketReceived(AgarPacket packet) { packet_received.Set(); // Signal any waiting threads if (PacketReceived != null) PacketReceived(this, packet); }