Don't idle logout if a transfer is making progress

This commit is contained in:
Bryan Ashby 2020-05-06 17:47:13 -06:00
parent 59ee52ea6f
commit 387dfb3b5d
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
2 changed files with 19 additions and 4 deletions

View File

@ -84,7 +84,7 @@ function Client(/*input, output*/) {
this.user = new User(); this.user = new User();
this.currentTheme = { info : { name : 'N/A', description : 'None' } }; this.currentTheme = { info : { name : 'N/A', description : 'None' } };
this.lastKeyPressMs = Date.now(); this.lastActivityTime = Date.now();
this.menuStack = new MenuStack(this); this.menuStack = new MenuStack(this);
this.acs = new ACS( { client : this, user : this.user } ); this.acs = new ACS( { client : this, user : this.user } );
this.mciCache = {}; this.mciCache = {};
@ -406,7 +406,7 @@ function Client(/*input, output*/) {
self.log.trace( { key : key, ch : escape(ch) }, 'User keyboard input'); // jshint ignore:line self.log.trace( { key : key, ch : escape(ch) }, 'User keyboard input'); // jshint ignore:line
} }
self.lastKeyPressMs = Date.now(); self.lastActivityTime = Date.now();
if(!self.ignoreInput) { if(!self.ignoreInput) {
self.emit('key press', ch, key); self.emit('key press', ch, key);
@ -438,7 +438,7 @@ Client.prototype.startIdleMonitor = function() {
this.stopIdleMonitor(); this.stopIdleMonitor();
} }
this.lastKeyPressMs = Date.now(); this.lastActivityTime = Date.now();
// //
// Every 1m, check for idle. // Every 1m, check for idle.
@ -476,7 +476,7 @@ Client.prototype.startIdleMonitor = function() {
// use override value if set // use override value if set
idleLogoutSeconds = this.idleLogoutSecondsOverride || idleLogoutSeconds; idleLogoutSeconds = this.idleLogoutSecondsOverride || idleLogoutSeconds;
if(idleLogoutSeconds > 0 && (nowMs - this.lastKeyPressMs >= (idleLogoutSeconds * 1000))) { if(idleLogoutSeconds > 0 && (nowMs - this.lastActivityTime >= (idleLogoutSeconds * 1000))) {
this.emit('idle timeout'); this.emit('idle timeout');
} }
}, 1000 * 60); }, 1000 * 60);
@ -489,6 +489,10 @@ Client.prototype.stopIdleMonitor = function() {
} }
}; };
Client.prototype.explicitActivityTimeUpdate = function() {
this.lastActivityTime = Date.now();
}
Client.prototype.overrideIdleLogoutSeconds = function(seconds) { Client.prototype.overrideIdleLogoutSeconds = function(seconds) {
this.idleLogoutSecondsOverride = seconds; this.idleLogoutSecondsOverride = seconds;
}; };

View File

@ -378,7 +378,16 @@ exports.getModule = class TransferFileModule extends MenuModule {
const externalProc = pty.spawn(cmd, args, spawnOpts); const externalProc = pty.spawn(cmd, args, spawnOpts);
let dataHits = 0;
const updateActivity = () => {
if (0 === (dataHits++ % 4)) {
this.client.explicitActivityTimeUpdate();
}
};
this.client.setTemporaryDirectDataHandler(data => { this.client.setTemporaryDirectDataHandler(data => {
updateActivity();
// needed for things like sz/rz // needed for things like sz/rz
if(external.escapeTelnet) { if(external.escapeTelnet) {
const tmp = data.toString('binary').replace(/\xff{2}/g, '\xff'); // de-escape const tmp = data.toString('binary').replace(/\xff{2}/g, '\xff'); // de-escape
@ -389,6 +398,8 @@ exports.getModule = class TransferFileModule extends MenuModule {
}); });
externalProc.on('data', data => { externalProc.on('data', data => {
updateActivity();
// needed for things like sz/rz // needed for things like sz/rz
if(external.escapeTelnet) { if(external.escapeTelnet) {
const tmp = data.toString('binary').replace(/\xff/g, '\xff\xff'); // escape const tmp = data.toString('binary').replace(/\xff/g, '\xff\xff'); // escape