This commit is contained in:
2026-05-10 21:06:32 +02:00
parent 8dc34072ac
commit 3b73624246
-24
View File
@@ -85,34 +85,12 @@ function connectWs() {
function wsSend(obj) {
ws.send(JSON.stringify(obj));
}
function gotLock() {
setTimeout(() => {
wsSend({action: "lock", "id": 0});
wsSend({action: "get_toplay"});
wsSend({action: "skipc"});
wsSend({action: "skipi"});
pollLockHeld = true;
}, 500 + (Math.random() * 2500))
}
function handleLockState(msg) {
if(msg[0] == true) pollLockHeld = false;
else gotLock();
}
function handleMessage(msg) {
switch (msg.event) {
case "state": {
const d = msg.data || {};
if(d.dirs) updateDirs(d.dirs);
if(d.track) applyProgressState(d.track);
if(d.locks) handleLockState(d.locks)
break;
}
case "lock": {
if(msg.error) pollLockHeld = false;
else if (msg.id == 0 && msg.data == false) gotLock();
break;
}
case "rds":
@@ -124,11 +102,9 @@ function handleMessage(msg) {
break;
case "new_track":
applyTrackState(msg.data);
if(pollLockHeld) {
wsSend({ action: "get_toplay" });
wsSend({ action: "skipc" });
wsSend({ action: "skipi" });
}
break;
case "progress":
applyProgressState(msg.data);