Skip to content

Commit

Permalink
Merge pull request Pycord-Development#1559 from Dorukyum/resume_gatew…
Browse files Browse the repository at this point in the history
…ay_url

Implement `resume_gateway_url`
  • Loading branch information
BobDotCom authored Aug 11, 2022
2 parents 9ebeaca + f71b47f commit 7418cd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def __init__(self, socket, *, loop):
# ws related stuff
self.session_id = None
self.sequence = None
self.resume_gateway_url = None
self._zlib = zlib.decompressobj()
self._buffer = bytearray()
self._close_code = None
Expand Down Expand Up @@ -511,6 +512,7 @@ async def received_message(self, msg, /):
self._trace = trace = data.get("_trace", [])
self.sequence = msg["s"]
self.session_id = data["session_id"]
self.resume_gateway_url = data["resume_gateway_url"]
# pass back shard ID to ready handler
data["__shard_id__"] = self.shard_id
_log.info(
Expand Down
6 changes: 5 additions & 1 deletion discord/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ async def reidentify(self, exc: ReconnectWebSocket) -> None:
async def reconnect(self) -> None:
self._cancel_task()
try:
coro = DiscordWebSocket.from_client(self._client, shard_id=self.id)
coro = DiscordWebSocket.from_client(
self._client,
gateway=self.ws.resume_gateway_url,
shard_id=self.id,
)
self.ws = await asyncio.wait_for(coro, timeout=60.0)
except self._handled_exceptions as e:
await self._handle_disconnect(e)
Expand Down

0 comments on commit 7418cd4

Please sign in to comment.