Add RESUME support.

This commit is contained in:
Rapptz
2016-06-01 05:13:15 -04:00
parent 20e86973ea
commit e0a91df32b
4 changed files with 54 additions and 12 deletions

View File

@ -401,9 +401,10 @@ class Client:
while not self.is_closed:
try:
yield from self.ws.poll_event()
except ReconnectWebSocket:
log.info('Reconnecting the websocket.')
self.ws = yield from DiscordWebSocket.from_client(self)
except (ReconnectWebSocket, ResumeWebSocket) as e:
resume = type(e) is ResumeWebSocket
log.info('Got ' + type(e).__name__)
self.ws = yield from DiscordWebSocket.from_client(self, resume=resume)
except ConnectionClosed as e:
yield from self.close()
if e.code != 1000: