use map instead
All checks were successful
/ test (push) Successful in 16s

This commit is contained in:
Soph :3 2024-04-27 15:10:55 +03:00
parent 0df211d65d
commit 86faf72ffc
Signed by: sophie
GPG key ID: EDA5D222A0C270F2

View file

@ -28,19 +28,14 @@ if(argv[0] == "--dev") {
const scriptName = Math.random().toFixed(10).replace("0.","")
const wss = new WebSocketServer({ port: 8081 });
let allConnections: any[] = [];
let allConnections = new Map<number, WebSocket>();
wss.on('connection', function connection(ws) {
//@ts-ignore
ws.id = Math.random();
//@ts-ignore
allConnections.push(ws);
const id = Math.random();
allConnections.set(id, ws as any);
ws.on('error', console.error);
ws.on("close", () => {
//@ts-ignore
allConnections = allConnections.filter(z => z.id != ws.id);
allConnections.delete(id);
})
});
const server = new Server(