* Code cleanup
* Placeholder concept of Bunyan child logger per connected client
This commit is contained in:
parent
8e0dc505b1
commit
fa7cf1f265
|
@ -153,7 +153,7 @@ function startListening() {
|
|||
// Start tracking the client. We'll assign it an ID which is
|
||||
// just the index in our connections array.
|
||||
//
|
||||
if(typeof client.runtime === 'undefined') {
|
||||
if(_.isUndefined(client.runtime)) {
|
||||
client.runtime = {};
|
||||
}
|
||||
|
||||
|
@ -195,6 +195,11 @@ function startListening() {
|
|||
function addNewClient(client) {
|
||||
var id = client.runtime.id = clientConnections.push(client) - 1;
|
||||
|
||||
// Create a client specific logger
|
||||
client.log = logger.log.child( { clientId : id } );
|
||||
|
||||
// :TODO: if client.log concept is kept, clean this up to use it:
|
||||
|
||||
var connInfo = {
|
||||
connectionCount : clientConnections.length,
|
||||
clientId : client.runtime.id,
|
||||
|
|
|
@ -44,62 +44,12 @@ var _ = require('lodash');
|
|||
|
||||
exports.Client = Client;
|
||||
|
||||
//var ANSI_CONTROL_REGEX = /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/g;
|
||||
|
||||
// :TODO: Move all of the key stuff to it's own module
|
||||
|
||||
//
|
||||
// Resources & Standards:
|
||||
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
|
||||
//
|
||||
var ANSI_KEY_NAME_MAP = {
|
||||
0x08 : 'backspace', // BS
|
||||
0x09 : 'tab', //
|
||||
0x7f : 'del',
|
||||
0x1b : 'esc',
|
||||
0x0d : 'enter',
|
||||
0x19 : 'end of medium', // EM / CTRL-Y
|
||||
};
|
||||
|
||||
var ANSI_KEY_CSI_NAME_MAP = {
|
||||
0x40 : 'insert', // @
|
||||
0x41 : 'up arrow', // A
|
||||
0x42 : 'down arrow', // B
|
||||
0x43 : 'right arrow', // C
|
||||
0x44 : 'left arrow', // D
|
||||
|
||||
0x48 : 'home', // H
|
||||
0x4b : 'end', // K
|
||||
|
||||
0x56 : 'page up', // V
|
||||
0x55 : 'page down', // U
|
||||
};
|
||||
|
||||
var ANSI_F_KEY_NAME_MAP_1 = {
|
||||
0x50 : 'F1',
|
||||
0x51 : 'F2',
|
||||
0x52 : 'F3',
|
||||
0x53 : 'F4',
|
||||
0x74 : 'F5',
|
||||
};
|
||||
|
||||
var ANSI_F_KEY_NAME_MAP_2 = {
|
||||
// rxvt
|
||||
11 : 'F1',
|
||||
12 : 'F2',
|
||||
13 : 'F3',
|
||||
14 : 'F4',
|
||||
15 : 'F5',
|
||||
|
||||
// SyncTERM
|
||||
17 : 'F6',
|
||||
18 : 'F7',
|
||||
19 : 'F8',
|
||||
20 : 'F9',
|
||||
21 : 'F10',
|
||||
23 : 'F11',
|
||||
24 : 'F12',
|
||||
};
|
||||
|
||||
// :TODO: put this in a common area!!!!
|
||||
function getIntArgArray(array) {
|
||||
|
@ -380,7 +330,8 @@ function Client(input, output) {
|
|||
}
|
||||
|
||||
if(key || ch) {
|
||||
Log.trace( { key : key, ch : ch }, 'User keyboard input');
|
||||
//Log.trace( { key : key, ch : ch }, 'User keyboard input');
|
||||
self.log.trace( { key : key, ch : ch }, 'User keyboard input');
|
||||
|
||||
self.emit('key press', ch, key);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue