Updates to idle monitor inc. ability to disable

This commit is contained in:
Bryan Ashby 2018-03-04 09:17:27 -07:00
parent d260011ce8
commit 44a4a4aeb4
1 changed files with 10 additions and 8 deletions

View File

@ -414,26 +414,28 @@ Client.prototype.setTermType = function(termType) {
}; };
Client.prototype.startIdleMonitor = function() { Client.prototype.startIdleMonitor = function() {
var self = this; this.lastKeyPressMs = Date.now();
self.lastKeyPressMs = Date.now();
// //
// Every 1m, check for idle. // Every 1m, check for idle.
// //
self.idleCheck = setInterval(function checkForIdle() { this.idleCheck = setInterval( () => {
const nowMs = Date.now(); const nowMs = Date.now();
const idleLogoutSeconds = self.user.isAuthenticated() ? const idleLogoutSeconds = this.user.isAuthenticated() ?
Config.misc.idleLogoutSeconds : Config.misc.idleLogoutSeconds :
Config.misc.preAuthIdleLogoutSeconds; Config.misc.preAuthIdleLogoutSeconds;
if(nowMs - self.lastKeyPressMs >= (idleLogoutSeconds * 1000)) { if(nowMs - this.lastKeyPressMs >= (idleLogoutSeconds * 1000)) {
self.emit('idle timeout'); this.emit('idle timeout');
} }
}, 1000 * 60); }, 1000 * 60);
}; };
Client.prototype.stopIdleMonitor = function() {
clearInterval(this.idleCheck);
};
Client.prototype.end = function () { Client.prototype.end = function () {
if(this.term) { if(this.term) {
this.term.disconnect(); this.term.disconnect();
@ -445,7 +447,7 @@ Client.prototype.end = function () {
currentModule.leave(); currentModule.leave();
} }
clearInterval(this.idleCheck); this.stopIdleMonitor();
try { try {
// //