public async void Connect(string ip, string token) { socket = new ClientWebSocket(); Log.Print($"Connecting to {ip}"); await socket.ConnectAsync(new Uri($"ws://{ip}"), CancellationToken.None); Log.Print("Connected"); await socket.Send(new ResetConnection1().GetBytes()); await socket.Send(new ResetConnection2().GetBytes()); await socket.Send(new SendToken(token).GetBytes()); for (;;) { while(packetQueue.Count > 0) await socket.Send(packetQueue.Dequeue().GetBytes()); incomingPackets.Enqueue(await socket.Receive()); } }