summary refs log tree commit diff
path: root/src/util/setHeartbeat.ts
blob: 1fe657a8796c93b5e6aa9b7159ea3c0dd841c899 (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 * 30);
}