mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-23 20:26:28 +00:00
30 lines
878 B
JavaScript
30 lines
878 B
JavaScript
"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
|