add heartbeat to fix connection closing when idle

This commit is contained in:
AlexandreRouma
2025-11-05 03:24:28 -05:00
parent 5140d34664
commit 8fd5143f99
2 changed files with 10 additions and 0 deletions

View File

@@ -223,6 +223,9 @@ func userHandler(sock *websocket.Conn) {
// Release the user's display pointer // Release the user's display pointer
user.displayMtx.Unlock(); user.displayMtx.Unlock();
case "hb":
// Nothing to do, just a heart beat...
default: default:
// Give up // Give up
break; break;

View File

@@ -74,6 +74,13 @@ class WisCastUserAPIClient {
dispID: dispID, dispID: dispID,
otp: OTP otp: OTP
})) }))
// Send a heart-beat message every 30 seconds
setInterval(async () => {
await this.#sock.send(JSON.stringify({
type: 'hb',
}))
}, 30000);
}); });
} }