14 lines
345 B
JavaScript
14 lines
345 B
JavaScript
function setupPing(ws) {
|
|
const interval = setInterval(() => {
|
|
if (ws.readyState === 1) {
|
|
ws.ping("ping");
|
|
} else {
|
|
clearInterval(interval);
|
|
}
|
|
}, 30000);
|
|
|
|
ws.on("pong", (data) => {
|
|
console.log("📡 PONG from client:", data.toString());
|
|
});
|
|
}
|
|
module.exports = { setupPing }; |