Rewrite RESUME logic to be more in line with what is requested.

Apparently we should always try to RESUME first and if we get
INVALIDATE_SESSION then we should IDENTIFY instead. This is the
preferred way to do RESUMEs.
This commit is contained in:
Rapptz
2017-02-08 04:37:16 -05:00
parent f5b455c119
commit dc486980f8
3 changed files with 13 additions and 24 deletions

View File

@ -54,10 +54,9 @@ class Shard:
def poll(self):
try:
yield from self.ws.poll_event()
except (ReconnectWebSocket, ResumeWebSocket) as e:
resume = type(e) is ResumeWebSocket
log.info('Got ' + type(e).__name__)
self.ws = yield from DiscordWebSocket.from_client(self._client, resume=resume,
except ResumeWebSocket as e:
log.info('Got a request to RESUME the websocket.')
self.ws = yield from DiscordWebSocket.from_client(self._client, resume=True,
shard_id=self.id,
session=self.ws.session_id,
sequence=self.ws.sequence)