aboutsummaryrefslogtreecommitdiff
path: root/discord/gateway.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-08-15 23:41:11 -0400
committerRapptz <[email protected]>2017-08-15 23:41:11 -0400
commit0f7482ed6e2bced618e1eb4979dcd450a6fb3afa (patch)
treeed1891205859868080c8ef6cff90ff61cd052fb3 /discord/gateway.py
parentRemove reason keyword argument from message deletion. (diff)
downloaddiscord.py-0f7482ed6e2bced618e1eb4979dcd450a6fb3afa.tar.xz
discord.py-0f7482ed6e2bced618e1eb4979dcd450a6fb3afa.zip
Add Client.latency, AutoShardedClient.latency and latencies.
This should allow an easier way to query the Discord protocol gateway latency, defined by the difference HEARTBEAT_ACK between and the last sent HEARTBEAT.
Diffstat (limited to 'discord/gateway.py')
-rw-r--r--discord/gateway.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/discord/gateway.py b/discord/gateway.py
index 50104034..e3825d26 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -346,6 +346,8 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
if op == self.HELLO:
interval = data['heartbeat_interval'] / 1000.0
self._keep_alive = KeepAliveHandler(ws=self, interval=interval, shard_id=self.shard_id)
+ # send a heartbeat immediately
+ yield from self.send_as_json(self._keep_alive.get_payload())
self._keep_alive.start()
return