Skip to content

Commit

Permalink
fix: use resume_gateway_url only on reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
eunwoo1104 committed Aug 21, 2022
1 parent 59e74f2 commit 2e84a94
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dico/ws/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
self.ws: aiohttp.ClientWebSocketResponse = ws
self.http: AsyncHTTPRequest = http
self.base_url: str = base_url
self.reconnect_url: str = ""
self.event_handler: EventHandler = event_handler
logger_name = "dico.ws"
if shard:
Expand Down Expand Up @@ -144,7 +145,10 @@ async def run(self):
while True:
try:
self.ws = await self.http.session.ws_connect(
self.base_url, **self.WS_KWARGS
self.base_url
if self._fresh_reconnecting
else self.reconnect_url,
**self.WS_KWARGS,
)
break
except: # noqa
Expand Down Expand Up @@ -205,7 +209,7 @@ async def process(self, resp) -> typing.Optional[int]:
if resp.op == gateway.Opcodes.DISPATCH:
if resp.t == "READY":
self.session_id = resp.d.get("session_id", self.session_id)
self.base_url = (
self.reconnect_url = (
resp.d["resume_gateway_url"] + "?" + self.base_url.split("?")[-1]
)
self.event_handler.client.dispatch("RAW", resp.raw)
Expand Down

0 comments on commit 2e84a94

Please sign in to comment.