aboutsummaryrefslogtreecommitdiff
path: root/discord/client.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-07 21:55:47 -0500
committerRapptz <[email protected]>2017-01-07 23:19:39 -0500
commit20041ea756305f20c86a621232639932c50f107c (patch)
treefc9be7da66b1dffd274d96f85dd1cb7c605e56c2 /discord/client.py
parentFix variable shadowing in READY parsing. (diff)
downloaddiscord.py-20041ea756305f20c86a621232639932c50f107c.tar.xz
discord.py-20041ea756305f20c86a621232639932c50f107c.zip
Implement AutoShardedClient for transparent sharding.
This allows people to run their >2,500 guild bot in a single process without the headaches of IPC/RPC or much difficulty.
Diffstat (limited to 'discord/client.py')
-rw-r--r--discord/client.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/discord/client.py b/discord/client.py
index 2e0696c9..f8f45870 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -142,6 +142,7 @@ class Client:
self.connection = ConnectionState(dispatch=self.dispatch, chunker=self.request_offline_members,
syncer=self._syncer, http=self.http, loop=self.loop, **options)
+ self.connection.shard_count = self.shard_count
self._closed = asyncio.Event(loop=self.loop)
self._is_logged_in = asyncio.Event(loop=self.loop)
self._is_ready = asyncio.Event(loop=self.loop)
@@ -405,11 +406,14 @@ class Client:
while not self.is_closed:
try:
- yield from self.ws.poll_event()
+ yield from ws.poll_event()
except (ReconnectWebSocket, ResumeWebSocket) as e:
resume = type(e) is ResumeWebSocket
log.info('Got ' + type(e).__name__)
- self.ws = yield from DiscordWebSocket.from_client(self, resume=resume)
+ self.ws = yield from DiscordWebSocket.from_client(self, shard_id=self.shard_id,
+ session=self.ws.session_id,
+ sequence=self.ws.sequence,
+ resume=resume)
except ConnectionClosed as e:
yield from self.close()
if e.code != 1000: