diff --git a/examples/dual-server.mjs b/examples/dual-server.mjs deleted file mode 100644 index 77f4a83..0000000 --- a/examples/dual-server.mjs +++ /dev/null @@ -1,64 +0,0 @@ -import Base from '../src/base' - -const USOCKET = __dirname + '/sample.sock' - -const delay = time => new Promise(res=>setTimeout(()=>res(),time)) - -; -(async () => { - - let app = new Base({com:'us,uc,ts,tc', tspp:'tcpProcess', id:'example', path: USOCKET, log:false}) - - // use an alternative packet processor for tcp - app.tcpProcess = async function (packet) { - if (!packet.cmd) return {error: 'no command in packet', packet: packet } - if (!this[packet.cmd]) return {error: 'no processing function supplied for command', packet: packet } - return await this.tcp[packet.cmd](packet) - } - - app.echo = async packet => { - packet.processed = true - packet.cmd = 'res' - console.log('ECHO!') - return packet - } - - app.tcp = {} - - app.tcp.echo = async packet => { - packet.processed = true - packet.info = 'via tcp processor and echo' - packet.cmd = 'res' - console.log('TCP ECHO!') - return packet - } - - app.write = async packet => { - console.log('packet with write command data received by server') - packet.cmd = 'res' - packet.processed = 'true' - packet.data = 'response from write' - return packet - } - - app.res = async packet => { - console.log('==============Packet returned from server==========') - console.dir(packet) - console.log('===========================') - } - - await app.init(app) - console.log('=============sending============') - let packet = {cmd:'echo', data:'some data to echo'} - app.send(packet) - // await delay(1000) - // packet = {cmd:'echo', data:'some MORE data to echo'} - // app.send(packet) - // // await delay(1000) - // packet = {cmd:'echo', data:'YET some data to echo'} - // app.send(packet) - - -})().catch(err => { - console.error('FATAL: UNABLE TO START SYSTEM!\n',err) -}) diff --git a/examples/four-in-one.mjs b/examples/four-in-one.mjs new file mode 100644 index 0000000..f0cd21e --- /dev/null +++ b/examples/four-in-one.mjs @@ -0,0 +1,40 @@ +import Base from '../src/base' + +const USOCKET = __dirname + '/sample.sock' + +const delay = time => new Promise(res=>setTimeout(()=>res(),time)) + +; +(async () => { + + // let app = new Base({com:'us,uc,ts,tc', id:'example', path: USOCKET, log:false}) + let app = new Base({com:'us,uc,ts,tc', id:'example'}) + + + await app.init() + console.log('ready=============sending============') + let packet = {cmd:'echo', data:'some data to echo'} + await app.send(packet) + app.write = function(packet){ + packet.cmd='log' + packet.response='return of write command' + return packet + } + app.write2 = function(packet){ + packet.cmd='log' + packet.response='return of write2 command' + return packet + } + app.registerPacketContext(app) + packet = {cmd:'write', data:'data to write'} + await app.send(packet) + packet = {cmd:'write2', data:'data to write'} + await app.send(packet) + + await delay(2000) + process.kill(process.pid, 'SIGTERM') + + +})().catch(err => { + console.error('FATAL: UNABLE TO START SYSTEM!\n',err) +}) diff --git a/log.log b/log.log deleted file mode 100644 index 1880eed..0000000 --- a/log.log +++ /dev/null @@ -1,15 +0,0 @@ -{"name":"uci-base-app","hostname":"trantor","pid":9197,"level":30,"msg":"listening","time":"2018-01-16T03:04:08.127Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":9497,"level":30,"msg":"listening","time":"2018-01-16T03:04:52.793Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":9782,"level":30,"packet":{"sender":"test consumer","cmd":"test","data":"some data"},"msg":"attempting to send packet to socket","time":"2018-01-16T03:06:19.485Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":11066,"level":30,"msg":"listening","time":"2018-01-16T03:19:19.403Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":11392,"level":30,"msg":"listening","time":"2018-01-16T03:20:21.646Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12527,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"socket created","time":"2018-01-16T03:29:27.556Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":12517,"level":30,"msg":"listening","time":"2018-01-16T03:29:27.938Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12527,"level":30,"msg":"\nhe's dead jim","time":"2018-01-16T03:29:39.682Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12698,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"socket created","time":"2018-01-16T03:30:39.131Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12698,"level":30,"msg":"\nhe's dead jim","time":"2018-01-16T03:33:07.420Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":13006,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"socket created","time":"2018-01-16T03:33:10.467Z","v":0} -{"name":"uci-base-app","hostname":"trantor","pid":12996,"level":30,"msg":"listening","time":"2018-01-16T03:33:10.839Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":13006,"level":30,"msg":"\nhe's dead jim","time":"2018-01-16T03:36:53.278Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":13393,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"socket created","time":"2018-01-16T03:36:55.038Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":13393,"level":30,"msg":"\nhe's dead jim","time":"2018-01-16T03:36:55.410Z","v":0} diff --git a/logfile.log b/logfile.log deleted file mode 100644 index 4d87817..0000000 --- a/logfile.log +++ /dev/null @@ -1,34 +0,0 @@ -2018-01-09 17:54:43.869 INFO data packet received to socket - [object Object] -2018-01-09 17:55:22.848 INFO data packet received to socket - [object Object] -2018-01-09 18:41:52.123 INFO data packet received to socket - [object Object] -2018-01-09 18:42:38.934 INFO data packet received to socket - [object Object] -2018-01-09 18:42:57.304 INFO data packet received to socket - [object Object] -2018-01-09 18:44:28.169 INFO data packet received to socket - [object Object] -2018-01-09 19:07:47.858 INFO data packet received to socket - [object Object] -2018-01-10 07:59:53.339 INFO data packet received to socket - [object Object] -2018-01-10 08:02:14.987 INFO data packet received to socket - [object Object] -2018-01-10 08:08:42.623 INFO data packet received to socket - [object Object] -2018-01-10 08:09:11.630 INFO data packet received to socket - [object Object] -2018-01-10 08:46:34.958 INFO data packet received to socket - [object Object] -2018-01-10 08:47:00.072 INFO data packet received to socket - [object Object] -2018-01-10 08:47:19.323 INFO data packet received to socket - [object Object] -2018-01-10 08:50:28.428 INFO data packet received to socket - [object Object] -2018-01-10 08:54:18.476 INFO data packet received to socket - [object Object] -2018-01-10 08:56:12.612 INFO data packet received to socket - [object Object] diff --git a/package.json b/package.json index 8fc888d..6b89978 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@uci/base", "version": "0.1.0", "description": "Mutli Level/Transport Message/Event Classes", - "main": "src/base.js", + "main": "src/base", "scripts": { "testw": "mocha -r @std/esm test/*.test.mjs --watch --recurse --watch-extensions mjs", "test": "mocha -r @std/esm test/*.test.mjs", @@ -36,9 +36,6 @@ "mocha": "^4.0.1" }, "dependencies": { - "@uci/socket": "^0.1.0", - "@uci/utils": "^0.1.0", - "auto-bind": "^1.1.0", - "delimiter-stream": "^1.0.1" + "@uci/socket": "^0.1.0" } } diff --git a/socket.log b/socket.log deleted file mode 100644 index a539ba1..0000000 --- a/socket.log +++ /dev/null @@ -1,248 +0,0 @@ -{"name":"example:ts","hostname":"trantor","pid":21731,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T03:44:08.666Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21731,"level":30,"msg":"listening","time":"2018-01-19T03:44:08.667Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21731,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:44:08.669Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21731,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:44:08.669Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21731,"level":30,"msg":"connecting","time":"2018-01-19T03:44:08.670Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21731,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:44:08.670Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21731,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:44:08.701Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21731,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:44:08.702Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21731,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:44:08.702Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21731,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T03:45:03.804Z","v":0} -{"name":"example:us","hostname":"trantor","pid":21986,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T03:45:04.813Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":21986,"level":30,"msg":"listening","time":"2018-01-19T03:45:04.815Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21986,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T03:45:04.814Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21986,"level":30,"msg":"listening","time":"2018-01-19T03:45:04.815Z","v":0} -{"name":"example:us","hostname":"trantor","pid":21986,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:45:04.817Z","v":0} -{"name":"example:us","hostname":"trantor","pid":21986,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:45:04.817Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":21986,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T03:45:04.818Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":21986,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:45:04.818Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21986,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:45:04.817Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21986,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:45:04.817Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21986,"level":30,"msg":"connecting","time":"2018-01-19T03:45:04.818Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21986,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:45:04.818Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":21986,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:45:04.850Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21986,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:45:04.850Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":21986,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:45:04.851Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":21986,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:45:04.851Z","v":0} -{"name":"example:us","hostname":"trantor","pid":21986,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:45:04.851Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21986,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:45:04.852Z","v":0} -{"name":"example:us","hostname":"trantor","pid":21986,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T03:48:28.606Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":21986,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T03:48:28.606Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22228,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T03:48:30.313Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22228,"level":30,"msg":"listening","time":"2018-01-19T03:48:30.314Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22228,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T03:48:30.314Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22228,"level":30,"msg":"listening","time":"2018-01-19T03:48:30.315Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22228,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:48:30.316Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22228,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:48:30.316Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22228,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T03:48:30.317Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22228,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:48:30.317Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22228,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:48:30.317Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22228,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:48:30.317Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22228,"level":30,"msg":"connecting","time":"2018-01-19T03:48:30.318Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22228,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:48:30.318Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22228,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:48:30.348Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22228,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:48:30.348Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22228,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:48:30.348Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22228,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:48:30.349Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22228,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:48:30.349Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22228,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:48:30.350Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22228,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T03:50:52.235Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22228,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T03:50:52.236Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22510,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T03:50:53.332Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22510,"level":30,"msg":"listening","time":"2018-01-19T03:50:53.333Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22510,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T03:50:53.333Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22510,"level":30,"msg":"listening","time":"2018-01-19T03:50:53.334Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22510,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:50:53.336Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22510,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:50:53.336Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22510,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T03:50:53.337Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22510,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:50:53.337Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22510,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T03:50:53.337Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22510,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T03:50:53.337Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22510,"level":30,"msg":"connecting","time":"2018-01-19T03:50:53.338Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22510,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T03:50:53.338Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22510,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:50:53.368Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22510,"level":30,"msg":"handshake done, connected","time":"2018-01-19T03:50:53.368Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":22510,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:50:53.369Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":22510,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T03:50:53.369Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22510,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:50:53.369Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22510,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T03:50:53.370Z","v":0} -{"name":"example:us","hostname":"trantor","pid":22510,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:22:11.024Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":22510,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:22:11.024Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24716,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:22:13.170Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24716,"level":30,"msg":"listening","time":"2018-01-19T04:22:13.172Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24716,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:22:13.171Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24716,"level":30,"msg":"listening","time":"2018-01-19T04:22:13.173Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24716,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:22:13.174Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24716,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:22:13.174Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24716,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:22:13.175Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24716,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:22:13.175Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24716,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:22:13.175Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24716,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:22:13.175Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24716,"level":30,"msg":"connecting","time":"2018-01-19T04:22:13.176Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24716,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:22:13.176Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24716,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:22:13.206Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24716,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:22:13.206Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24716,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:22:13.207Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24716,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:22:13.207Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24716,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:22:13.207Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24716,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:22:13.208Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24716,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:22:47.356Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24716,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:22:47.357Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24818,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:22:48.444Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24818,"level":30,"msg":"listening","time":"2018-01-19T04:22:48.445Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24818,"level":30,"msg":"listening","time":"2018-01-19T04:22:48.446Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24818,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:22:48.445Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24818,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:22:48.447Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24818,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:22:48.447Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24818,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:22:48.448Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24818,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:22:48.449Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24818,"level":30,"msg":"connecting","time":"2018-01-19T04:22:48.449Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24818,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:22:48.449Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24818,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:22:48.448Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24818,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:22:48.448Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24818,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:22:48.479Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24818,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:22:48.479Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":24818,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:22:48.480Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":24818,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:22:48.480Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24818,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:22:48.481Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24818,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:22:48.481Z","v":0} -{"name":"example:us","hostname":"trantor","pid":24818,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:24:12.269Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":24818,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:24:12.269Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25001,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:24:15.282Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25001,"level":30,"msg":"listening","time":"2018-01-19T04:24:15.283Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25001,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:24:15.283Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25001,"level":30,"msg":"listening","time":"2018-01-19T04:24:15.284Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25001,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:24:15.286Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25001,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:24:15.287Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25001,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:24:15.285Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25001,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:24:15.285Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25001,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:24:15.286Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25001,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:24:15.286Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25001,"level":30,"msg":"connecting","time":"2018-01-19T04:24:15.287Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25001,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:24:15.287Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25001,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:24:15.317Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25001,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:24:15.317Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25001,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:24:15.318Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25001,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:24:15.318Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25001,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:24:15.319Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25001,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:24:15.319Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25001,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:25:37.308Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25001,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:25:37.309Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25165,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:25:39.013Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25165,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:25:39.014Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25165,"level":30,"msg":"listening","time":"2018-01-19T04:25:39.015Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25165,"level":30,"msg":"listening","time":"2018-01-19T04:25:39.014Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25165,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:25:39.016Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25165,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:25:39.016Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25165,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:25:39.017Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25165,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:25:39.017Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25165,"level":30,"msg":"connecting","time":"2018-01-19T04:25:39.018Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25165,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:25:39.018Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25165,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:25:39.017Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25165,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:25:39.017Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25165,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:25:39.048Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25165,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:25:39.048Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25165,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:25:39.048Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25165,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:25:39.048Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25165,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:25:39.049Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25165,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:25:39.049Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25165,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:26:35.417Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25165,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:26:35.417Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25356,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:26:36.891Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25356,"level":30,"msg":"listening","time":"2018-01-19T04:26:36.893Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25356,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:26:36.892Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25356,"level":30,"msg":"listening","time":"2018-01-19T04:26:36.894Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25356,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:26:36.896Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25356,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:26:36.896Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25356,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:26:36.897Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25356,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:26:36.897Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25356,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:26:36.897Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25356,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:26:36.897Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25356,"level":30,"msg":"connecting","time":"2018-01-19T04:26:36.898Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25356,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:26:36.898Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25356,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:26:36.928Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25356,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:26:36.928Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25356,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:26:36.928Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25356,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:26:36.929Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25356,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:26:36.929Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25356,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:26:36.929Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25356,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:29:04.611Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25356,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:29:04.611Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25541,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:29:06.035Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25541,"level":30,"msg":"listening","time":"2018-01-19T04:29:06.037Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25541,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:29:06.036Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25541,"level":30,"msg":"listening","time":"2018-01-19T04:29:06.037Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25541,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:29:06.039Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25541,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:29:06.040Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25541,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:29:06.038Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25541,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:29:06.038Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25541,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:29:06.039Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25541,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:29:06.039Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25541,"level":30,"msg":"connecting","time":"2018-01-19T04:29:06.040Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25541,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:29:06.040Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25541,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:29:06.070Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25541,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:29:06.070Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":25541,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:29:06.071Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":25541,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:29:06.071Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25541,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:29:06.071Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25541,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:29:06.072Z","v":0} -{"name":"example:us","hostname":"trantor","pid":25541,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:36:21.048Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":25541,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:36:21.048Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26135,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:36:22.965Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26135,"level":30,"msg":"listening","time":"2018-01-19T04:36:22.967Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26135,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:36:22.966Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26135,"level":30,"msg":"listening","time":"2018-01-19T04:36:22.967Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26135,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:36:22.970Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26135,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:36:22.970Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26135,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:36:22.969Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26135,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:36:22.969Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26135,"level":30,"msg":"connecting","time":"2018-01-19T04:36:22.970Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26135,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:36:22.971Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26135,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:36:22.969Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26135,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:36:22.969Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26135,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:36:23.001Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26135,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:36:23.001Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26135,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:36:23.001Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26135,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:36:23.002Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26135,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:36:23.002Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26135,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:36:23.003Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26135,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:36:44.458Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26135,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:36:44.458Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26222,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:36:45.284Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26222,"level":30,"msg":"listening","time":"2018-01-19T04:36:45.285Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26222,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:36:45.285Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26222,"level":30,"msg":"listening","time":"2018-01-19T04:36:45.286Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26222,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:36:45.288Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26222,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:36:45.288Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26222,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:36:45.288Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26222,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:36:45.288Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26222,"level":30,"msg":"connecting","time":"2018-01-19T04:36:45.290Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26222,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:36:45.290Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26222,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:36:45.289Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26222,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:36:45.289Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26222,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:36:45.320Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26222,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:36:45.320Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26222,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:36:45.320Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26222,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:36:45.320Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26222,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:36:45.321Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26222,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:36:45.321Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26222,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:40:46.019Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26222,"level":30,"msg":"\nhe's dead jim","time":"2018-01-19T04:40:46.020Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26643,"level":30,"socket":{"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock"},"msg":"socket created","time":"2018-01-19T04:41:16.401Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26643,"level":30,"msg":"listening","time":"2018-01-19T04:41:16.403Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26643,"level":30,"socket":{"host":"127.0.0.1","port":8080},"msg":"socket created","time":"2018-01-19T04:41:16.402Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26643,"level":30,"msg":"listening","time":"2018-01-19T04:41:16.403Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26643,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:41:16.405Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26643,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:41:16.405Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26643,"level":30,"path":"/home/david/AllData/hacking/active-dev-repos/uci/uci-base/examples/sample.sock","msg":"connecting","time":"2018-01-19T04:41:16.406Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26643,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:41:16.406Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26643,"level":30,"msg":"server: new consumer connecting","time":"2018-01-19T04:41:16.405Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26643,"level":30,"msg":"Server: sending handshake to consumer","time":"2018-01-19T04:41:16.405Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26643,"level":30,"msg":"connecting","time":"2018-01-19T04:41:16.406Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26643,"level":30,"msg":"waiting for 30ms for handshake","time":"2018-01-19T04:41:16.407Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26643,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:41:16.437Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26643,"level":30,"msg":"handshake done, connected","time":"2018-01-19T04:41:16.437Z","v":0} -{"name":"example:uc","hostname":"trantor","pid":26643,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:41:16.437Z","v":0} -{"name":"example:tc","hostname":"trantor","pid":26643,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"attempting to send packet to socket","time":"2018-01-19T04:41:16.437Z","v":0} -{"name":"example:us","hostname":"trantor","pid":26643,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:41:16.438Z","v":0} -{"name":"example:ts","hostname":"trantor","pid":26643,"level":30,"packet":{"cmd":"echo","data":"some data to echo"},"msg":"Server: packet received to socket","time":"2018-01-19T04:41:16.438Z","v":0} diff --git a/src/base.mjs b/src/base.mjs index a0c8d94..259451a 100644 --- a/src/base.mjs +++ b/src/base.mjs @@ -1,56 +1,68 @@ -import { Socket, Consumer } from '../../uci-socket/src' -// import { Socket as TCPSocket, Consumer as TCPConsumer } from '@uci/tcp-socket' +import { Socket, Consumer } from '@uci/socket' +import packet from './packet.mjs' import EventEmitter from 'events' -// import autoBind from 'auto-bind' + +const USOCKET = __dirname + '/unix.sock' export default class Base extends EventEmitter { constructor(opts={}) { super() + opts.path = opts.path || USOCKET this.id = opts.id // a unique ecosystem wide id, could be generated this.desc = opts.desc // additional details for humans // attach unix socket OR consumer(default) only if path is supplied - this.socket = [] - this.consumer = [] + this.socket={} this.com = opts.com.split(/[,:|\s]+/) this.com.forEach( sock => { opts.name = this.id +':'+sock + opts.type = sock switch (sock) { case 'us': - opts.spp = opts.uspp ? opts.uspp : opts.spp - this.socket.push(new Socket(opts.path,opts)) + this.socket[sock] = new Socket(opts.path,opts) break case 'uc': - this.consumer.push(new Consumer(opts.path,opts)) + this.socket[sock] = new Consumer(opts.path,opts) break case 'ts': - opts.spp = opts.tspp ? opts.tspp : opts.spp - this.socket.push(new Socket(opts)) + this.socket[sock]= new Socket(opts) break case 'tc': - this.consumer.push(new Consumer(opts)) + this.socket[sock]= new Consumer(opts) } }) - - // autoBind(this) - } // end constructor -// this override default echo processor needs command 'cmd' as a minimum. Will pass data and sender property - async processPacket(packet) { - if (!packet.cmd) return {error: 'no command in packet', packet: packet } - if (!this[packet.cmd]) return {error: 'no processing function supplied for command', packet: packet } - return await this[packet.cmd](packet) + async init (context) { + context = context || this // context is Base if not supplied + for(let type of Object.keys(this.socket)){ + if (type.indexOf('s')!==-1) { + this.socket[type].packet = packet.socket + await this.socket[type].create(context) + } + else { + this.socket[type].packet = packet.consumer + await this.socket[type].connect(context) + } + } + } // init + + registerPacketContext(context) { + for(let type of Object.keys(this.socket)){ + this.socket[type].registerPacketContext(context) + } } - async init () { - await Promise.all(this.socket.map( sock => sock.create(this))) - return Promise.all(this.consumer.map( con => con.connect(this))) - } // init + registerPacketProcessor(func) { + for(let type of Object.keys(this.socket)){ + this.socket[type].registerPacketProcessor(func) + } + } async send (packet) { this.emit(packet.cmd, packet) - return await Promise.all(this.consumer.map(con => con.send(packet))) + if (this.socket.uc) await this.socket.uc.send(packet) + if (this.socket.tc) await this.socket.tc.send(packet) } } // end class diff --git a/src/packet.mjs b/src/packet.mjs new file mode 100644 index 0000000..61bb9e9 --- /dev/null +++ b/src/packet.mjs @@ -0,0 +1,45 @@ + + +export default { + + socket:{ + _process: async function (packet) { + if (!packet.cmd) return {error: 'no command in packet', packet: packet } + if (this.context) if (this.context[packet.cmd]) return await this.context[packet.cmd].bind(this.context)(packet) + if (this[packet.cmd]) return await this[packet.cmd](packet) + return {error: 'no socket processing function supplied for command', packet: packet } + }, + echo: packet => { + packet.processed = true + packet.cmd = 'log' + packet.info = 'echoed' + return packet + } + }, + + consumer: { + _process: async function (packet) { + if (packet.error) return this.error(packet) + if (packet.cmd) { + if (this.context) if (this.context[packet.cmd]) return await this.context[packet.cmd].bind(this.context)(packet) + if (this[packet.cmd]) return await this[packet.cmd](packet) + packet = {error:'no consumer processing function supplied for command',packet:packet} + return this.error(packet) + } else { + packet = {error:'no command in packet',packet:packet} + return this.error(packet) + } + }, + error: function (packet) { + console.log('==============Packet ERROR==========') + console.log(packet.error ) + console.dir(packet.packet) + console.log('===========================') + }, + log: packet => { + console.log('==============Packet returned from socket==========') + console.dir(packet) + console.log('===========================') + } + } +} diff --git a/test/base.socket.mjs b/test/base.socket.mjs deleted file mode 100644 index 443931f..0000000 --- a/test/base.socket.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import Base from '../src/base' -const USOCKET = '/opt/sockets/samplecs.sock' - -let server = new Base({id:'uci-base-server', desc:'socket server', usocket: true, path:USOCKET}) - -server.test = async (packet) => { - packet.processed = true - return packet -} - -; -(async () => { - -// using default packet processor - await server.usocket.create() - -})().catch(err => { - console.error('FATAL: UNABLE TO START SYSTEM!\n',err) -}) diff --git a/test/log.log b/test/log.log deleted file mode 100644 index ee973aa..0000000 --- a/test/log.log +++ /dev/null @@ -1,3 +0,0 @@ -{"name":"uci-base-server","hostname":"trantor","pid":12374,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"already exists...deleting","time":"2018-01-16T03:28:36.376Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12374,"level":30,"socket":"/opt/sockets/samplecs.sock","msg":"socket created","time":"2018-01-16T03:28:36.378Z","v":0} -{"name":"uci-base-server","hostname":"trantor","pid":12374,"level":30,"msg":"\nhe's dead jim","time":"2018-01-16T03:28:39.265Z","v":0}