From 31dc5be41b11999989daaa9e33c33b0de17357f7 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Fri, 5 May 2023 14:46:29 +0200 Subject: [PATCH] fix ping 2 --- src/websocket.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/websocket.ts b/src/websocket.ts index 886d262..141db31 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -30,6 +30,7 @@ wss.on('connection', function connection(ws: WebSocket & { isAlive: boolean }, r ) } ws.onmessage = function (msg) { + console.log(msg.data) if (msg.data === "pong") { ws.isAlive = true } @@ -39,6 +40,7 @@ wss.on('connection', function connection(ws: WebSocket & { isAlive: boolean }, r const interval = setInterval(function ping() { wss.clients.forEach(function each(ws) { + console.log("isAlive :" + (ws as WebSocket & { isAlive: boolean }).isAlive) if ((ws as WebSocket & { isAlive: boolean }).isAlive === false) return ws.terminate(); (ws as WebSocket & { isAlive: boolean }).isAlive = false;