UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

21 lines 723 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const message_1 = require("@cocalc/util/message"); const heartbeat_1 = require("@cocalc/util/heartbeat"); function initHeartbeat(socket) { let alive = true; const stop = () => (alive = false); socket.on("end", stop); socket.on("close", stop); socket.on("error", stop); const sendHeartbeat = () => { if (!alive) return; socket.write_mesg("json", (0, message_1.heartbeat)()); setTimeout(sendHeartbeat, heartbeat_1.PROJECT_HUB_HEARTBEAT_INTERVAL_S * 1000); }; // start the heart beating! sendHeartbeat(); } exports.default = initHeartbeat; //# sourceMappingURL=heartbeat.js.map