summary refs log tree commit diff
path: root/src/util/setHeartbeat.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 17:08:08 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 17:08:08 +0100
commit471d1d6b28f8a6b62680408756e389e8a0b71be0 (patch)
treef95518dd3e846734feaeee613aa3f37f43dcde62 /src/util/setHeartbeat.ts
parentuntrack DS_Store (diff)
downloadserver-471d1d6b28f8a6b62680408756e389e8a0b71be0.tar.xz
:sparkles: Base Server
Diffstat (limited to 'src/util/setHeartbeat.ts')
-rw-r--r--src/util/setHeartbeat.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/setHeartbeat.ts b/src/util/setHeartbeat.ts
new file mode 100644

index 00000000..1fe657a8 --- /dev/null +++ b/src/util/setHeartbeat.ts
@@ -0,0 +1,10 @@ +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(4009); + }, 1000 * 30); +}