Compare commits

..

No commits in common. "3e5296ac252b9b5c780bfb6b34d5b373667d27c5" and "3537634d17bc367f4245557a4a89489136efa86e" have entirely different histories.

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.id = i; break; }
for (let i = 0; i < 256; i++) if (!t.includes(i)) { ws.user = 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) => {
}
});
});
});