aboutsummaryrefslogtreecommitdiff
path: root/discord/gateway.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-04-09 02:46:26 -0400
committerRapptz <[email protected]>2020-07-25 09:59:38 -0400
commit058a1e608b29e56aa06c97ac9feb2f9915a6124d (patch)
tree62c7e42b7fbabcc85f8784dbef2b387dd6ddb8f3 /discord/gateway.py
parentUse a proper type for the event queue (diff)
downloaddiscord.py-058a1e608b29e56aa06c97ac9feb2f9915a6124d.tar.xz
discord.py-058a1e608b29e56aa06c97ac9feb2f9915a6124d.zip
Fix voice websocket connections
Diffstat (limited to 'discord/gateway.py')
-rw-r--r--discord/gateway.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/discord/gateway.py b/discord/gateway.py
index 59dd3c1a..1f82c9ef 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -503,7 +503,7 @@ class DiscordWebSocket:
raise msg.data
elif msg.type in (aiohttp.WSMsgType.CLOSED, aiohttp.WSMsgType.CLOSE):
log.debug('Received %s', msg)
- raise WebSocketClosure('Unexpected WebSocket closure.')
+ raise WebSocketClosure
except WebSocketClosure as e:
if self._can_handle_close():
log.info('Websocket closed with %s, attempting a reconnect.', self.socket.close_code)
@@ -638,8 +638,9 @@ class DiscordVoiceWebSocket:
CLIENT_CONNECT = 12
CLIENT_DISCONNECT = 13
- def __init__(self, socket):
+ def __init__(self, socket, loop):
self.ws = socket
+ self.loop = loop
self._keep_alive = None
async def send_as_json(self, data):
@@ -676,8 +677,8 @@ class DiscordVoiceWebSocket:
"""Creates a voice websocket for the :class:`VoiceClient`."""
gateway = 'wss://' + client.endpoint + '/?v=4'
http = client._state.http
- socket = await http.ws_connect(gateway)
- ws = cls(socket)
+ socket = await http.ws_connect(gateway, compress=15)
+ ws = cls(socket, loop=client.loop)
ws.gateway = gateway
ws._connection = client
ws._max_heartbeat_timeout = 60.0