mirror of
https://github.com/AlexandreRouma/wiscast.git
synced 2026-04-20 08:22:42 +00:00
add heartbeat to fix connection closing when idle
This commit is contained in:
3
user.go
3
user.go
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user