Compare commits
2 Commits
3537634d17
...
3e5296ac25
Author | SHA1 | Date | |
---|---|---|---|
3e5296ac25 | |||
8112a65204 |
@ -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)]
|
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);
|
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();
|
if (!ws.user.id) return ws.close();
|
||||||
|
|
||||||
console.log("join", ws.user);
|
console.log("join", ws.user);
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: "load",
|
type: "load",
|
||||||
id: ws.user.id,
|
id: ws.user.id,
|
||||||
@ -75,4 +75,4 @@ wss.on("connection", (ws, req) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user