You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
man
This commit is contained in:
@@ -166,7 +166,7 @@
|
|||||||
renderPlaylist();
|
renderPlaylist();
|
||||||
} else if(msg.event === "new_track"){
|
} else if(msg.event === "new_track"){
|
||||||
applyTrackState(msg.data);
|
applyTrackState(msg.data);
|
||||||
ws.send(JSON.stringify({action:"get_toplay"}))
|
ws.send(JSON.stringify({action:"get_toplay"}));
|
||||||
} else if(msg.event === "progress"){
|
} else if(msg.event === "progress"){
|
||||||
applyProgressState(msg.data);
|
applyProgressState(msg.data);
|
||||||
} else if(msg.event === "toplay") {
|
} else if(msg.event === "toplay") {
|
||||||
|
|||||||
@@ -84,15 +84,14 @@ async def broadcast_worker(ws_q: multiprocessing.Queue, clients: set):
|
|||||||
"""
|
"""
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
while True:
|
while True:
|
||||||
try: msg = await asyncio.wait_for(loop.run_in_executor(None, ws_q.get), 1.0)
|
msg = await loop.run_in_executor(None, ws_q.get)
|
||||||
except asyncio.TimeoutError: continue
|
|
||||||
if msg is None: break
|
if msg is None: break
|
||||||
payload = json.dumps(msg)
|
payload = json.dumps(msg)
|
||||||
if clients:
|
if clients:
|
||||||
await asyncio.gather(
|
coros = []
|
||||||
*[_safe_send(ws, payload, clients) for ws in list(clients)],
|
for ws in list(clients):
|
||||||
return_exceptions=True
|
coros.append(_safe_send(ws, payload, clients))
|
||||||
)
|
await asyncio.gather(*coros)
|
||||||
|
|
||||||
|
|
||||||
async def _safe_send(ws, payload: str, clients: set):
|
async def _safe_send(ws, payload: str, clients: set):
|
||||||
|
|||||||
Reference in New Issue
Block a user