This repository has been archived on 2026-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
2021-10-02 15:12:47 +02:00

12 lines
366 B
TypeScript

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);
}