From a8512db65b74ff87e1ac114f4acd95eadd5617c0 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Fri, 5 May 2023 14:48:49 +0200 Subject: [PATCH] fix ping when client is sending one to the server --- src/websocket.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/websocket.ts b/src/websocket.ts index faffaee..ea1eea0 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -30,9 +30,11 @@ 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 + return ws.isAlive = true + } + if (msg.data === "ping") { + return ws.send("pong") } } ws.send("ping");