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.
This commit is contained in:
Jake 2016-06-05 20:29:54 -07:00
parent b9c7b05176
commit 41a2b5ed73
2 changed files with 11 additions and 1 deletions

View File

@ -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)

View File

@ -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|