You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
bro
This commit is contained in:
@@ -11,7 +11,7 @@ from . import Track, PlayerModule, Path
|
|||||||
|
|
||||||
MAIN_PATH_DIR = Path("/home/user/mixes")
|
MAIN_PATH_DIR = Path("/home/user/mixes")
|
||||||
|
|
||||||
async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: multiprocessing.Queue, ws_q: multiprocessing.Queue):
|
async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: multiprocessing.Queue):
|
||||||
try:
|
try:
|
||||||
initial = {
|
initial = {
|
||||||
"playlist": json.loads(shared_data.get("playlist", "[]")),
|
"playlist": json.loads(shared_data.get("playlist", "[]")),
|
||||||
@@ -90,10 +90,10 @@ async def broadcast_worker(ws_q: multiprocessing.Queue, clients: set):
|
|||||||
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):
|
||||||
@@ -118,7 +118,7 @@ def websocket_server_process(shared_data: dict, imc_q: multiprocessing.Queue, ws
|
|||||||
async def handler_wrapper(websocket: ServerConnection):
|
async def handler_wrapper(websocket: ServerConnection):
|
||||||
# register client
|
# register client
|
||||||
clients.add(websocket)
|
clients.add(websocket)
|
||||||
try: await ws_handler(websocket, shared_data, imc_q, ws_q)
|
try: await ws_handler(websocket, shared_data, imc_q)
|
||||||
finally:
|
finally:
|
||||||
await websocket.close(1001, "")
|
await websocket.close(1001, "")
|
||||||
clients.discard(websocket)
|
clients.discard(websocket)
|
||||||
|
|||||||
Reference in New Issue
Block a user