diff options
| author | Rapptz <[email protected]> | 2016-06-02 07:32:35 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-06-02 07:32:35 -0400 |
| commit | f6fa1e837a3672d7e6cc276a58a71c7c8cf7eca7 (patch) | |
| tree | 29608f01479a220e3d3f24163f7c18b36f263002 /discord/gateway.py | |
| parent | Update positions when a role is added or removed. (diff) | |
| download | discord.py-f6fa1e837a3672d7e6cc276a58a71c7c8cf7eca7.tar.xz discord.py-f6fa1e837a3672d7e6cc276a58a71c7c8cf7eca7.zip | |
Actually use v4 gateway and fixes thanks to Jake.
Diffstat (limited to 'discord/gateway.py')
| -rw-r--r-- | discord/gateway.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/discord/gateway.py b/discord/gateway.py index 4d2c9cca..a569e464 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -125,7 +125,7 @@ def get_gateway(token, *, loop=None): yield from resp.release() raise GatewayNotFound() data = yield from resp.json(encoding='utf-8') - return data.get('url') + return data.get('url') + '?encoding=json&v=4' class DiscordWebSocket(websockets.client.WebSocketClientProtocol): """Implements a WebSocket for Discord's gateway v4. @@ -310,6 +310,9 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): if op == self.INVALIDATE_SESSION: state.sequence = None state.session_id = None + if data == True: + raise ResumeWebSocket() + yield from self.identify() return @@ -381,10 +384,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): except websockets.exceptions.ConnectionClosed as e: if self._can_handle_close(e.code): log.info('Websocket closed with {0.code} ({0.reason}), attempting a reconnect.'.format(e)) - if e.code == 4006: - raise ReconnectWebSocket() from e - else: - raise ResumeWebSocket() from e + raise ResumeWebSocket() from e else: raise ConnectionClosed(e) from e |