summary refs log tree commit diff
path: root/src/util/setHeartbeat.ts
blob: a59dd2511bc46542982d894ba9f86f74bfb3f488 (plain) (blame)
1
2
3
4
5
6
7
8
9
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 * 45);
}