Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

...
 
Commits (2)
  • Deucе's avatar
    getkey() can return undefined. · 168f54f3
    Deucе authored
    168f54f3
  • Deucе's avatar
    Deal with dorkit hangup issues... commit #1 · 9a89f8c9
    Deucе authored
    1) Ciolib CIO_KEY_QUIT and CIO_KEY_MOUSE conflicted with ALT_7 and ALT_6
       respectively, change these to use \xE0 prefixes.
    2) Add a new dorkit key "CONNECTION_CLOSED" which is returned by getkey()
       after the connection is closed.
    3) Have the various connection back-ends send a CONNECTION_CLOSED key to
       the keyboard buffer when the connection is closed.
    4) Have the local console send a CONNECTION_CLOSED key when the window
       is closed.
    5) Disable auto_terminate in dorkit.
    6) Introduce dk.connection.disconnect_timeout variable (defaults to 30
       seconds).  After a CONNECTION_CLOSED key is received, dorkit will
       immediately set js.terminated, then after disconnect_timeout seconds,
       will enable js.auto_terminate.
    7) After a CONNECTION_CLOSED key, waitkey() always returns true, getkey()
       always returns a CONNECTION_CLOSED key, and getbyte() always returns
       undefined.
    8) To prevent a poorly written door from hogging 100% CPU for the whole
       30 seconds, put an mswait(1) in the connection check when the
       inactivity timer is running.
    9a89f8c9
......@@ -189,5 +189,8 @@ var ai={
this.ansi_started = 0;
}
return;
}
},
close:function() {
this.input_queue.write("CONNECTION_CLOSED");
},
};
......@@ -12,3 +12,4 @@ while(!js.terminated) {
ai.add(k);
}
}
ai.close();
......@@ -2,6 +2,7 @@
* Implements the local console using conio
*/
var dk_local_console_terminated = false;
require('graphic.js', 'Graphic');
if (js.global.conio !== undefined && dk.console.local) {
conio.init();
......@@ -11,6 +12,12 @@ if (js.global.conio !== undefined && dk.console.local) {
dk.console.input_queue_callback.push(function() {
'use strict';
if (js.terminated !== dk_local_console_terminated) {
dk_local_console_terminated = js.terminated;
return(dk.console.key.CONNECTION_CLOSED);
}
if (dk_local_console_terminated)
return undefined;
var ch;
if (conio.kbhit) {
ch = conio.getch();
......@@ -67,6 +74,16 @@ if (js.global.conio !== undefined && dk.console.local) {
}
return undefined;
}
else if (ch == 0xe0) {
if (conio.kbhit) {
ch = conio.getch();
switch(ch) {
case 0x7e:
return dk.console.key.CONNECTION_CLOSED;
}
}
return undefined;
}
return ascii(ch);
}
......
......@@ -12,3 +12,4 @@ while(!js.terminated) {
k = console.inkey(0, 100);
ai.add(k);
}
ai.close();
......@@ -67,6 +67,8 @@ while(!js.terminated) {
k = undefined;
if (socket_select([sock], 0.1).length == 1) {
k = telnet.interpret(sock.read(1));
if (k === '')
break;
}
if (k != undefined && k.length) {
for(i=0; i<k.length; i++)
......@@ -75,3 +77,4 @@ while(!js.terminated) {
else
ai.add('');
}
ai.close();
/*jslint bitwise, this, devel, getset, for*/
// TODO: Auto-pause stuff...
js.auto_terminate = false;
js.load_path_list.unshift(js.exec_dir+"dorkit/");
js.on_exit("js.load_path_list.shift()");
if (js.global.system !== undefined) {
......@@ -130,7 +131,8 @@ var dk = {
KEY_ALT_9:'KEY_ALT_9',
KEY_ALT_0:'KEY_ALT_0',
POSITION_REPORT:'POSITION_REPORT',
UNKNOWN_ANSI:'UNKNOWN_ANSI'
UNKNOWN_ANSI:'UNKNOWN_ANSI',
CONNECTION_CLOSED:'CONNECTION_CLOSED'
},
x:1, // Current column (1-based)
......@@ -471,6 +473,31 @@ var dk = {
*/
input_queue_callback:[],
Private_connection_close:function() {
dk.connection.active = false;
if (dk.connection.inactive_time === undefined)
dk.connection.inactive_time = system.timer;
js.terminated = true;
},
Private_connection_check:function() {
var elapsed;
if (dk.connection.inactive_time !== undefined) {
elapsed = system.timer - dk.connection.inactive_time;
if (elapsed > dk.connection.disconnect_timeout)
js.auto_terminate = true;
mswait(1);
return true;
}
else if (js.terminated) {
dk.connection.inactive_time = system.timer;
mswait(1);
return true;
}
return false;
},
/*
* Waits up to timeout millisections and returns true if a key
* is pressed before the timeout. For ANSI sequences, returns
......@@ -482,6 +509,8 @@ var dk = {
var d;
var end = (new Date()).valueOf() + timeout;
if (this.Private_connection_check())
return true;
if (this.keybuf.length > 0) {
return true;
}
......@@ -518,9 +547,13 @@ var dk = {
var ret;
var m;
if (this.Private_connection_check())
return this.key.CONNECTION_CLOSED;
if (this.keybuf.length > 0) {
ret = this.keybuf.shift();
return ret;
if (ret !== this.key.CONNECTION_CLOSED)
return ret;
this.Private_connection_close();
}
if (!this.waitkey(0)) {
return undefined;
......@@ -570,10 +603,14 @@ var dk = {
'use strict';
var ret;
if (this.Private_connection_check())
return undefined;
while (1) {
if (this.keybuf.length > 0) {
do {
ret = this.keybuf.shift();
if (ret === this.key.CONNECTION_CLOSED)
this.Private_connection_close();
} while(ret.length > 1 && ret.indexOf('\x00') === -1);
return ret;
}
......@@ -856,7 +893,10 @@ var dk = {
error_correcting:true,
time:undefined,
socket:undefined,
telnet:false
telnet:false,
active:true,
inactive_time:undefined,
disconnect_timeout:30
},
user:{
full_name:undefined,
......
......@@ -698,8 +698,8 @@ CIOLIBEXPORT void CIOLIBCALL mousestate_res(int *x_res, int *y_res, uint8_t *but
#define CIO_KEY_ALT_F(x) ((x<11)?((0x67 + x) << 8):((0x80 + x) << 8))
#define CIO_KEY_BACKTAB (0x0f << 8)
#define CIO_KEY_MOUSE 0x7d00 // This is the right mouse on Schneider/Amstrad PC1512 PC keyboards "F-14"
#define CIO_KEY_QUIT 0x7e00 // "F-15"
#define CIO_KEY_MOUSE 0x7dE0 // This is the right mouse on Schneider/Amstrad PC1512 PC keyboards "F-14"
#define CIO_KEY_QUIT 0x7eE0 // "F-15"
#define CIO_KEY_ABORTED 0x01E0 // ESC key by scancode
#endif /* Do not add anything after this line */
......@@ -548,7 +548,7 @@ function getkey()
ch = '\x00';
do {
ch = getkeyw();
if (ch === null || ch.length < 1) {
if (ch === undefined || ch === null || ch.length < 1) {
ch = '\x00';
}
} while (ch === '\x00');
......