Update last_send when receiving a HEARTBEAT request

This commit is contained in:
Rapptz
2026-02-22 16:59:18 -05:00
parent 38d5d8e47a
commit f780f04447

View File

@@ -210,6 +210,10 @@ class KeepAliveHandler(threading.Thread):
def tick(self) -> None: def tick(self) -> None:
self._last_recv = time.perf_counter() self._last_recv = time.perf_counter()
def beat(self) -> Dict[str, Any]:
self._last_send = time.perf_counter()
return self.get_payload()
def ack(self) -> None: def ack(self) -> None:
ack_time = time.perf_counter() ack_time = time.perf_counter()
self._last_ack = ack_time self._last_ack = ack_time
@@ -541,7 +545,7 @@ class DiscordWebSocket:
if op == self.HEARTBEAT: if op == self.HEARTBEAT:
if self._keep_alive: if self._keep_alive:
beat = self._keep_alive.get_payload() beat = self._keep_alive.beat()
await self.send_as_json(beat) await self.send_as_json(beat)
return return