Example #1
0
async def send_sounds(ws: websockets.server.WebSocketServerProtocol,
                      ch: Channel):
    """
    Regularly sends the currently running sounds.
    """
    while True:
        try:
            await ws.send(
                json.dumps(list(map(lambda s: s.toJSON(), ch.get_sounds()))))
        except websockets.exceptions.ConnectionClosed:
            return
        await asyncio.sleep(0.1)