summary refs log tree commit diff
path: root/gateway/src/util/Heartbeat.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-02 15:12:47 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-02 15:12:47 +0200
commit1716d92849633476690dd660a68b2992d0f467bf (patch)
tree1f9d56f5c09895f59aaa8ded28bcfa7560c41a8b /gateway/src/util/Heartbeat.ts
parentMerge pull request #410 from TheArcaneBrony/master (diff)
downloadserver-1716d92849633476690dd660a68b2992d0f467bf.tar.xz
:art: restructure gateway
Diffstat (limited to 'gateway/src/util/Heartbeat.ts')
-rw-r--r--gateway/src/util/Heartbeat.ts11
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); +}