mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-07-29 23:39:15 +02:00
toggle official and remove are index addressed
This commit is contained in:
+9
-3
@@ -60,7 +60,7 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
|
||||
if action == "skip":
|
||||
imc_q.put({"name": "procman", "data": {"op": 2}})
|
||||
await websocket.send(json.dumps({"event": "skip"}))
|
||||
elif action == "add_to_toplay" or action == "remove_toplay":
|
||||
elif action == "add_to_toplay":
|
||||
songs = msg.get("songs")
|
||||
at_top = msg.get("top", False)
|
||||
if not isinstance(songs, list): await websocket.send(json.dumps({"error": "songs must be a list"}))
|
||||
@@ -69,6 +69,14 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
|
||||
result = await get_imc("activemod", {"action": "get_toplay"})
|
||||
if result is not None:
|
||||
await broadcast({"data": result, "event": "toplay"})
|
||||
elif action == "remove_toplay" or action == "toggle_official_toplay":
|
||||
idx = msg.get("indexes")
|
||||
if not isinstance(songs, list): await websocket.send(json.dumps({"error": "songs must be a list"}))
|
||||
else:
|
||||
imc_q.put({"name": "activemod", "data": {"action": action, "indexes": idx}})
|
||||
result = await get_imc("activemod", {"action": "get_toplay"})
|
||||
if result is not None:
|
||||
await broadcast({"data": result, "event": "toplay"})
|
||||
elif action == "get_toplay":
|
||||
result = await get_imc("activemod", {"action": "get_toplay"})
|
||||
if result is None: await websocket.send(json.dumps({"error": "timeout", "code": 504}))
|
||||
@@ -142,7 +150,6 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
|
||||
else:
|
||||
locks[lid] = websocket
|
||||
await broadcast({"event": "lock", "id": lid, "data": True})
|
||||
|
||||
elif action == "unlock":
|
||||
lid = msg.get("id")
|
||||
if lid is None:
|
||||
@@ -153,7 +160,6 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
|
||||
else:
|
||||
locks[lid] = None
|
||||
await broadcast({"event": "lock", "id": lid, "data": False})
|
||||
|
||||
else: await websocket.send(json.dumps({"event": "error", "error": "unknown action"}))
|
||||
finally:
|
||||
# release every lock this client held on disconnect
|
||||
|
||||
Reference in New Issue
Block a user