From 4aefd190f7315324e66ca5b7dd2b9bde7691a573 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 17 Oct 2015 02:41:13 -0300 Subject: [PATCH] Wait for the encryption key before returning from VoiceSocket.WaitForConnection() --- src/Discord.Net/WebSockets/Voice/VoiceWebSocket.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Discord.Net/WebSockets/Voice/VoiceWebSocket.cs b/src/Discord.Net/WebSockets/Voice/VoiceWebSocket.cs index 9930b066f..6156e84d8 100644 --- a/src/Discord.Net/WebSockets/Voice/VoiceWebSocket.cs +++ b/src/Discord.Net/WebSockets/Voice/VoiceWebSocket.cs @@ -26,7 +26,6 @@ namespace Discord.WebSockets.Voice private readonly int _targetAudioBufferLength; private OpusEncoder _encoder; private readonly ConcurrentDictionary _decoders; - private ManualResetEventSlim _connectWaitOnLogin; private uint _ssrc; private ConcurrentDictionary _ssrcMapping; @@ -50,7 +49,6 @@ namespace Discord.WebSockets.Voice : base(client) { _rand = new Random(); - _connectWaitOnLogin = new ManualResetEventSlim(false); _decoders = new ConcurrentDictionary(); _sendQueue = new ConcurrentQueue(); _sendQueueWait = new ManualResetEventSlim(true); @@ -247,8 +245,6 @@ namespace Discord.WebSockets.Voice int port = packet[68] | packet[69] << 8; string ip = Encoding.ASCII.GetString(packet, 4, 70 - 6).TrimEnd('\0'); - EndConnect(); - var login2 = new Login2Command(); login2.Payload.Protocol = "udp"; login2.Payload.SocketData.Address = ip; @@ -503,7 +499,7 @@ namespace Discord.WebSockets.Voice var payload = (msg.Payload as JToken).ToObject(); _secretKey = payload.SecretKey; SendIsTalking(true); - _connectWaitOnLogin.Set(); + EndConnect(); } break; case 5: