Compare commits

..

2 Commits

Author SHA1 Message Date
3e5296ac25 Merge branch 'master' of gitea.moe:lamp/piano 2021-12-03 01:35:30 -06:00
8112a65204 fix 2021-12-03 01:34:41 -06:00

View File

@ -32,11 +32,11 @@ wss.on("connection", (ws, req) => {
color: [Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)]
}
let t = Array.from(wss.clients).map(ws => ws.user.id);
for (let i = 0; i < 256; i++) if (!t.includes(i)) { ws.user = i; break; }
for (let i = 0; i < 256; i++) if (!t.includes(i)) { ws.user.id = i; break; }
if (!ws.user.id) return ws.close();
console.log("join", ws.user);
ws.send(JSON.stringify({
type: "load",
id: ws.user.id,
@ -75,4 +75,4 @@ wss.on("connection", (ws, req) => {
}
});
});
});