MCPcopy Create free account
hub / github.com/UnsignedInt8/LightSword / startRemainingTimer

Method startRemainingTimer

server/server.ts:166–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164 }
165
166 private startRemainingTimer() {
167 let me = this;
168
169 this.remainingTime = this.expireDate ? (<any>(new Date(this.expireDate)) - <any>new Date()) : undefined;
170 if (!this.remainingTime) return me.stopRemainingTimer();
171
172 if (this.remainingTime <= 0) {
173 return process.nextTick(() => {
174 console.info(`${me.port} expired. ${me.expireDate} ${me.remainingTime}`);
175 me.stop();
176 });
177 }
178
179 this.stopRemainingTimer();
180
181 this.remainingTimer = setInterval(() => {
182 me.remainingTime -= LsServer.expireRefreshInterval;
183 if (me.remainingTime > 0) return;
184
185 console.info(`${me.port} expired. ${me.expireDate} ${me.remainingTime}`);
186 me.stop();
187 }, LsServer.expireRefreshInterval);
188
189 this.remainingTimer.unref();
190 }
191
192 private stopRemainingTimer() {
193 if (!this.remainingTimer) return;

Callers 2

startMethod · 0.95
updateConfigurationMethod · 0.95

Calls 5

stopRemainingTimerMethod · 0.95
nextTickMethod · 0.80
infoMethod · 0.80
stopMethod · 0.80
unrefMethod · 0.65

Tested by

no test coverage detected