Improved inactivity timeout and function key detection
This commit is contained in:
parent
17ddda1cd5
commit
5293c8cb33
@ -49,6 +49,9 @@ var INACTIVE ='\1n\1h\1RINACTIVITY DISCONNECT';
|
|||||||
|
|
||||||
var NO_HISTORY_FRAMES =['980a','98b','981a'];
|
var NO_HISTORY_FRAMES =['980a','98b','981a'];
|
||||||
var SYSTEM_OWNER =9;
|
var SYSTEM_OWNER =9;
|
||||||
|
var INKEY_TIMEOUT =10000;
|
||||||
|
var INACTIVE_NOLOGIN =1000;
|
||||||
|
var INACTIVE_LOGIN =5*60000;
|
||||||
|
|
||||||
// Our frame object
|
// Our frame object
|
||||||
function TexFrame() {
|
function TexFrame() {
|
||||||
|
@ -218,7 +218,7 @@ function pageEditor(page) {
|
|||||||
log(LOG_DEBUG,' - pageEditor: p='+p+'('+p.length+') user ['+JSON.stringify(frameusers)+'] - :'+frameusers.indexOf(user.number.toString()));
|
log(LOG_DEBUG,' - pageEditor: p='+p+'('+p.length+') user ['+JSON.stringify(frameusers)+'] - :'+frameusers.indexOf(user.number.toString()));
|
||||||
|
|
||||||
var re = new RegExp('^' + p, 'g');
|
var re = new RegExp('^' + p, 'g');
|
||||||
if (page.toString().match(re) && (frameusers.indexOf(user.number.toString()) == 1)) {
|
if (page.toString().match(re) && (frameusers.indexOf(user.number.toString()) !== -1)) {
|
||||||
pageditor = true;
|
pageditor = true;
|
||||||
throw BreakException;
|
throw BreakException;
|
||||||
}
|
}
|
||||||
|
57
main.js
57
main.js
@ -26,7 +26,7 @@ while(bbs.online) {
|
|||||||
var next_page = user.number ? { frame: 98,index: 'b' } : { frame: 980,index: 'a' }; // Start Frame
|
var next_page = user.number ? { frame: 98,index: 'b' } : { frame: 980,index: 'a' }; // Start Frame
|
||||||
|
|
||||||
var action = ACTION_GOTO; // Initial action
|
var action = ACTION_GOTO; // Initial action
|
||||||
var inkey_timeout = 60000; // Timeout waiting for input
|
var inkey_timeout = INKEY_TIMEOUT; // Timeout waiting for input
|
||||||
var fo = null; // Current Frame
|
var fo = null; // Current Frame
|
||||||
var fn = null; // Current Field Number for an Input Frame
|
var fn = null; // Current Field Number for an Input Frame
|
||||||
var fe = null; // Frame to edit
|
var fe = null; // Frame to edit
|
||||||
@ -38,23 +38,65 @@ while(bbs.online) {
|
|||||||
var timeout = false; // Track our inactivity timeout
|
var timeout = false; // Track our inactivity timeout
|
||||||
var timer = time();
|
var timer = time();
|
||||||
var control = []; // Methods that need to process input
|
var control = []; // Methods that need to process input
|
||||||
|
var extendedkey = ''; // Current Extended Key being captured
|
||||||
|
|
||||||
ansi.send('ext_mode','clear','cursor');
|
ansi.send('ext_mode','clear','cursor');
|
||||||
|
|
||||||
while (action != ACTION_TERMINATE && action !=ACTION_EXIT) {
|
while (action != ACTION_TERMINATE && action !=ACTION_EXIT) {
|
||||||
bbs.nodesync(false); // @todo Stop the display of telegrams
|
bbs.nodesync(false); // @todo Stop the display of telegrams
|
||||||
read = '';
|
var read = '';
|
||||||
|
var esc = false;
|
||||||
|
|
||||||
// If we have no action, read from the terminal
|
// If we have no action, read from the terminal
|
||||||
if (action == false) {
|
if (action == false) {
|
||||||
|
|
||||||
|
while (esc || ! read) {
|
||||||
|
log(LOG_DEBUG,'- READ START');
|
||||||
read = console.inkey(K_NONE,inkey_timeout);
|
read = console.inkey(K_NONE,inkey_timeout);
|
||||||
|
|
||||||
if (read == '' && ! (user.security.exemptions&UFLAG_H) ) {
|
// We are intering a special keyboard char.
|
||||||
if (time() > timer+inkey_timeout/1000) {
|
if (read == KEY_ESC) {
|
||||||
|
log(LOG_DEBUG,'- READ SPECIAL KEY COMING');
|
||||||
|
esc = true;
|
||||||
|
inkey_timeout = 200;
|
||||||
|
|
||||||
|
} else if (esc && ! extendedkey && read != '[') {
|
||||||
|
log(LOG_DEBUG,'- READ SPECIAL KEY ABANDONED: ['+read+'] ('+read.charCodeAt(0)+')');
|
||||||
|
esc = false;
|
||||||
|
inkey_timeout = INKEY_TIMEOUT;
|
||||||
|
read = KEY_ESC;
|
||||||
|
|
||||||
|
} else if (esc && extendedkey && (read == '~' || read == ';')) {
|
||||||
|
switch (extendedkey) {
|
||||||
|
case '[15': read = false; break; // F5
|
||||||
|
case '[17': read = false; break; // F6
|
||||||
|
case '[18': read = false; break; // F7
|
||||||
|
case '[19': read = false; break; // F8
|
||||||
|
case '[20': read = false; break; // F9
|
||||||
|
case '[21': read = false; break; // F10
|
||||||
|
case '[23': read = false; break; // F11
|
||||||
|
case '[24': read = false; break; // F12
|
||||||
|
default:
|
||||||
|
log(LOG_DEBUG,'- READ UNKNOWN KEY: ['+extendedkey+']');
|
||||||
|
read = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
esc = false;
|
||||||
|
extendedkey = '';
|
||||||
|
inkey_timeout = INKEY_TIMEOUT;
|
||||||
|
|
||||||
|
} else if (esc) {
|
||||||
|
log(LOG_DEBUG,'- READ SPECIAL KEY ['+read+'] ('+read.charCodeAt(0)+')');
|
||||||
|
extendedkey += read;
|
||||||
|
read = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read === '' && ! (user.security.exemptions&UFLAG_H) ) {
|
||||||
|
if (time() > timer+((user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)+INKEY_TIMEOUT)/1000) {
|
||||||
sendBaseline(INACTIVE,false);
|
sendBaseline(INACTIVE,false);
|
||||||
bbs.hangup();
|
bbs.hangup();
|
||||||
|
|
||||||
} else {
|
} else if (time() > timer+(user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)/1000) {
|
||||||
timeout = true;
|
timeout = true;
|
||||||
sendBaseline(INACTIVITY,false);
|
sendBaseline(INACTIVITY,false);
|
||||||
|
|
||||||
@ -73,6 +115,11 @@ while(bbs.online) {
|
|||||||
timer = time();
|
timer = time();
|
||||||
timeout = false;
|
timeout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (esc) {
|
||||||
|
log(LOG_DEBUG,'- READ SHOULD LOOP');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log(LOG_DEBUG,'READ: ['+read+'] ('+read.charCodeAt(0)+')');
|
log(LOG_DEBUG,'READ: ['+read+'] ('+read.charCodeAt(0)+')');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user