mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Add support for resume_gateway_url
This commit is contained in:
@ -682,6 +682,8 @@ class Client:
|
||||
_log.info('Got a request to %s the websocket.', e.op)
|
||||
self.dispatch('disconnect')
|
||||
ws_params.update(sequence=self.ws.sequence, resume=e.resume, session=self.ws.session_id)
|
||||
if e.resume:
|
||||
ws_params['gateway'] = self.ws.gateway
|
||||
continue
|
||||
except (
|
||||
OSError,
|
||||
@ -705,7 +707,13 @@ class Client:
|
||||
|
||||
# If we get connection reset by peer then try to RESUME
|
||||
if isinstance(exc, OSError) and exc.errno in (54, 10054):
|
||||
ws_params.update(sequence=self.ws.sequence, initial=False, resume=True, session=self.ws.session_id)
|
||||
ws_params.update(
|
||||
sequence=self.ws.sequence,
|
||||
gateway=self.ws.gateway,
|
||||
initial=False,
|
||||
resume=True,
|
||||
session=self.ws.session_id,
|
||||
)
|
||||
continue
|
||||
|
||||
# We should only get this when an unhandled close code happens,
|
||||
@ -725,7 +733,12 @@ class Client:
|
||||
# Always try to RESUME the connection
|
||||
# If the connection is not RESUME-able then the gateway will invalidate the session.
|
||||
# This is apparently what the official Discord client does.
|
||||
ws_params.update(sequence=self.ws.sequence, resume=True, session=self.ws.session_id)
|
||||
ws_params.update(
|
||||
sequence=self.ws.sequence,
|
||||
gateway=self.ws.gateway,
|
||||
resume=True,
|
||||
session=self.ws.session_id,
|
||||
)
|
||||
|
||||
async def close(self) -> None:
|
||||
"""|coro|
|
||||
|
Reference in New Issue
Block a user