diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-02 15:12:47 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-02 15:12:47 +0200 |
commit | 7bd0a2004c9d7f1c59b510a5462b82c4b0a0ce7a (patch) | |
tree | 4e77c193c08b2acb234981a6244836e1c5398bcf /gateway/src/util/Heartbeat.ts | |
parent | Merge pull request #410 from TheArcaneBrony/master (diff) | |
download | server-7bd0a2004c9d7f1c59b510a5462b82c4b0a0ce7a.tar.xz |
:art: restructure gateway
Diffstat (limited to 'gateway/src/util/Heartbeat.ts')
-rw-r--r-- | gateway/src/util/Heartbeat.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gateway/src/util/Heartbeat.ts b/gateway/src/util/Heartbeat.ts new file mode 100644 index 00000000..f6871cfe --- /dev/null +++ b/gateway/src/util/Heartbeat.ts @@ -0,0 +1,11 @@ +import { CLOSECODES } from "./Constants"; +import { WebSocket } from "./WebSocket"; + +// TODO: make heartbeat timeout configurable +export function setHeartbeat(socket: WebSocket) { + if (socket.heartbeatTimeout) clearTimeout(socket.heartbeatTimeout); + + socket.heartbeatTimeout = setTimeout(() => { + return socket.close(CLOSECODES.Session_timed_out); + }, 1000 * 45); +} |