This commit is contained in:
parent
0df211d65d
commit
86faf72ffc
13
src/build.ts
13
src/build.ts
|
@ -28,19 +28,14 @@ if(argv[0] == "--dev") {
|
||||||
const scriptName = Math.random().toFixed(10).replace("0.","")
|
const scriptName = Math.random().toFixed(10).replace("0.","")
|
||||||
|
|
||||||
const wss = new WebSocketServer({ port: 8081 });
|
const wss = new WebSocketServer({ port: 8081 });
|
||||||
let allConnections: any[] = [];
|
let allConnections = new Map<number, WebSocket>();
|
||||||
|
|
||||||
wss.on('connection', function connection(ws) {
|
wss.on('connection', function connection(ws) {
|
||||||
//@ts-ignore
|
const id = Math.random();
|
||||||
ws.id = Math.random();
|
allConnections.set(id, ws as any);
|
||||||
//@ts-ignore
|
|
||||||
|
|
||||||
allConnections.push(ws);
|
|
||||||
|
|
||||||
ws.on('error', console.error);
|
ws.on('error', console.error);
|
||||||
ws.on("close", () => {
|
ws.on("close", () => {
|
||||||
//@ts-ignore
|
allConnections.delete(id);
|
||||||
allConnections = allConnections.filter(z => z.id != ws.id);
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const server = new Server(
|
const server = new Server(
|
||||||
|
|
Loading…
Reference in a new issue