IOTConnect-Web/node_modules/mqtt/build/lib/PingTimer.js

30 lines
878 B
JavaScript
Raw Normal View History

2024-05-09 01:49:52 +00:00
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const timers_1 = __importDefault(require("./timers"));
class PingTimer {
constructor(keepalive, checkPing) {
this.keepalive = keepalive * 1000;
this.checkPing = checkPing;
this.reschedule();
}
clear() {
if (this.timer) {
timers_1.default.clear(this.timer);
this.timer = null;
}
}
reschedule() {
this.clear();
this.timer = timers_1.default.set(() => {
this.checkPing();
if (this.timer) {
this.reschedule();
}
}, this.keepalive);
}
}
exports.default = PingTimer;
//# sourceMappingURL=PingTimer.js.map