diff options
| author | Jake <[email protected]> | 2016-06-05 20:29:54 -0700 |
|---|---|---|
| committer | Jake <[email protected]> | 2016-06-05 21:18:36 -0700 |
| commit | 41a2b5ed73aa5e39a6cd207a61c1aaaa69b8171e (patch) | |
| tree | 41135e8e5ac36c37daf8f12e4fe7d4400b861498 /discord | |
| parent | [commands] Unify Command.handle_local_error into general dispatcher. (diff) | |
| download | discord.py-41a2b5ed73aa5e39a6cd207a61c1aaaa69b8171e.tar.xz discord.py-41a2b5ed73aa5e39a6cd207a61c1aaaa69b8171e.zip | |
Actually read from the voice websocket & fix heartbeat.
This change makes it so that the buffer doesn't fill and the voice server drops the socket.
Also, use correct interval for voice websocket heartbeat.
Diffstat (limited to 'discord')
| -rw-r--r-- | discord/gateway.py | 2 | ||||
| -rw-r--r-- | discord/voice_client.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/discord/gateway.py b/discord/gateway.py index a569e464..3a81b991 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -549,7 +549,7 @@ class DiscordVoiceWebSocket(websockets.client.WebSocketClientProtocol): data = msg.get('d') if op == self.READY: - interval = (data['heartbeat_interval'] / 100.0) - 5 + interval = data['heartbeat_interval'] / 1000.0 self._keep_alive = VoiceKeepAliveHandler(ws=self, interval=interval) self._keep_alive.start() yield from self.initial_connection(data) diff --git a/discord/voice_client.py b/discord/voice_client.py index d923cba0..a49b3a35 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -225,6 +225,16 @@ class VoiceClient: self._connected.set() break + self.loop.create_task(self.poll_voice_ws()) + + @asyncio.coroutine + def poll_voice_ws(self): + """|coro| + Reads from the voice websocket while connected. + """ + while self._connected.is_set(): + yield from self.ws.poll_event() + @asyncio.coroutine def disconnect(self): """|coro| |