fix ping when client is sending one to the server
This commit is contained in:
+4
-2
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user