From e3922e24d96cd10b2e20b694dc657331980d5fab Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 12 Aug 2020 22:16:39 -0400 Subject: Correct some protocol errors in v4 of voice gateway --- discord/gateway.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'discord/gateway.py') diff --git a/discord/gateway.py b/discord/gateway.py index 81ff69b8..382d60f1 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -635,8 +635,8 @@ class DiscordVoiceWebSocket: Sent only. Tells the client to resume its session. HELLO Receive only. Tells you that your websocket connection was acknowledged. - INVALIDATE_SESSION - Sent only. Tells you that your RESUME request has failed and to re-IDENTIFY. + RESUMED + Sent only. Tells you that your RESUME request has succeeded. CLIENT_CONNECT Indicates a user has connected to voice. CLIENT_DISCONNECT @@ -652,7 +652,7 @@ class DiscordVoiceWebSocket: HEARTBEAT_ACK = 6 RESUME = 7 HELLO = 8 - INVALIDATE_SESSION = 9 + RESUMED = 9 CLIENT_CONNECT = 12 CLIENT_DISCONNECT = 13 @@ -755,9 +755,8 @@ class DiscordVoiceWebSocket: await self.initial_connection(data) elif op == self.HEARTBEAT_ACK: self._keep_alive.ack() - elif op == self.INVALIDATE_SESSION: - log.info('Voice RESUME failed.') - await self.identify() + elif op == self.RESUMED: + log.info('Voice RESUME succeeded.') elif op == self.SESSION_DESCRIPTION: self._connection.mode = data['mode'] await self.load_secret_key(data) @@ -773,7 +772,9 @@ class DiscordVoiceWebSocket: state.endpoint_ip = data['ip'] packet = bytearray(70) - struct.pack_into('>I', packet, 0, state.ssrc) + struct.pack_into('>H', packet, 0, 1) # 1 = Send + struct.pack_into('>H', packet, 2, 70) # 70 = Length + struct.pack_into('>I', packet, 4, state.ssrc) state.socket.sendto(packet, (state.endpoint_ip, state.voice_port)) recv = await self.loop.sock_recv(state.socket, 70) log.debug('received packet in initial_connection: %s', recv) @@ -794,8 +795,6 @@ class DiscordVoiceWebSocket: await self.select_protocol(state.ip, state.port, mode) log.info('selected the voice protocol for use (%s)', mode) - await self.client_connect() - @property def latency(self): """:class:`float`: Latency between a HEARTBEAT and its HEARTBEAT_ACK in seconds.""" -- cgit v1.2.3