fix ping when client is sending one to the server

This commit is contained in:
2023-05-05 14:48:49 +02:00
parent 7114ac9c64
commit a8512db65b
+4 -2
View File
@@ -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");