From df0c6407c1c06cf3fe92bb0b26f7a448ba0263e1 Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Wed, 23 Mar 2016 00:07:37 -0700 Subject: [PATCH] major revisions to binary, hex and other rawBuffer sockets --- README.md | 134 +++++++++++++----- dao/client.js | 34 ++--- dao/socketServer.js | 45 +++--- entities/Defaults.js | 10 ++ entities/LogColors.js | 15 -- .../Multi-Client-Broadcast/goodbye-client.js | 8 +- .../Multi-Client-Broadcast/hello-client.js | 10 +- .../Multi-Client-Broadcast/world-server.js | 6 +- example/TCPSocket/basic/hello-client.js | 8 +- example/TCPSocket/basic/world-server.js | 6 +- example/TCPSocket/basicSync/hello-client.js | 8 +- example/TCPSocket/basicSync/world-server.js | 4 +- example/TCPSocket/rawBuffer/hello-client.js | 6 +- example/TCPSocket/rawBuffer/world.server.js | 4 +- .../goodbye-client.js | 8 +- .../hello-client.js | 10 +- .../world-server.js | 6 +- .../basic-local-only/hello-client.js | 8 +- .../basic-local-only/world-server.js | 4 +- .../basic-more-secure/hello-client.js | 8 +- .../basic-more-secure/world-server.js | 4 +- .../basic-most-secure/hello-client.js | 8 +- .../basic-most-secure/world-server.js | 4 +- example/TLSSocket/basic/hello-client.js | 8 +- example/TLSSocket/basic/world-server.js | 4 +- example/TLSSocket/basicSync/hello-client.js | 8 +- example/TLSSocket/basicSync/world-server.js | 4 +- .../hello-client.js | 6 +- .../world.server.js | 4 +- .../Multi-Client-Broadcast/goodbye-client.js | 16 +-- .../Multi-Client-Broadcast/hello-client.js | 18 +-- .../Multi-Client-Broadcast/world-server.js | 22 +-- example/UDPSocket/basic/hello-client.js | 4 +- example/UDPSocket/basic/world-server.js | 5 +- example/UDPSocket/rawBuffer/hello-client.js | 4 +- example/UDPSocket/rawBuffer/world.server.js | 4 +- example/rawBuffer/hello-client.js | 43 ++++++ example/rawBuffer/world.server.js | 40 ++++++ .../Multi-Client-Broadcast/goodbye-client.js | 8 +- .../Multi-Client-Broadcast/hello-client.js | 10 +- .../Multi-Client-Broadcast/world-server.js | 12 +- .../unixWindowsSocket/basic/hello-client.js | 8 +- .../unixWindowsSocket/basic/world-server.js | 7 +- .../basicSync/hello-client.js | 8 +- .../basicSync/world-server.js | 4 +- .../rawBuffer/hello-client.js | 6 +- .../rawBuffer/world.server.js | 4 +- node-ipc.js | 7 +- package.json | 2 +- services/IPC.js | 10 +- 50 files changed, 388 insertions(+), 246 deletions(-) delete mode 100644 entities/LogColors.js create mode 100644 example/rawBuffer/hello-client.js create mode 100644 example/rawBuffer/world.server.js diff --git a/README.md b/README.md index 8fd0397..e925d78 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ You may want to install jasmine and istanbul globally with ` sudo npm install -g #### Contents 1. [Types of IPC Sockets and Supporting OS](#types-of-ipc-sockets) +1. [IPC Config](#ipc-config) 2. [IPC Methods](#ipc-methods) 1. [log](#log) 2. [connectTo](#connectto) @@ -46,13 +47,14 @@ You may want to install jasmine and istanbul globally with ` sudo npm install -g 6. [serveNet](#servenet) 3. [IPC Stores and Default Variables](#ipc-stores-and-default-variables) 4. [IPC Events](#ipc-events) -5. [Basic Examples](#basic-examples) +5. [Multiple IPC instances](#multiple-ipc-instances) +6. [Basic Examples](#basic-examples) 1. [Server for Unix||Windows Sockets & TCP Sockets](#server-for-unix-sockets--tcp-sockets) 2. [Client for Unix||Windows Sockets & TCP Sockets](#client-for-unix-sockets--tcp-sockets) 4. [Server & Client for UDP Sockets](#server--client-for-udp-sockets) - 5. [Raw Buffers or Binary Sockets](#raw-buffer-or-binary-sockets) -6. [Working with TLS/SSL Socket Servers & Clients](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) -7. [Advanced Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example) + 5. [Raw Buffers, Real Time and / or Binary Sockets](#raw-buffer-or-binary-sockets) +7. [Working with TLS/SSL Socket Servers & Clients](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) +8. [Node Code Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example) ---- @@ -73,6 +75,8 @@ You may want to install jasmine and istanbul globally with ` sudo npm install -g ---- +#### IPC Config + `ipc.config` Set these variables in the `ipc.config` scope to overwrite or set default values. @@ -89,6 +93,8 @@ Set these variables in the `ipc.config` scope to overwrite or set default values rawBuffer : false, sync : false, silent : false, + logInColor : true, + logDepth : 5, maxConnections : 100, retry : 500, maxRetries : false, @@ -104,10 +110,12 @@ Set these variables in the `ipc.config` scope to overwrite or set default values | id | the id of this socket or service | | networkHost| the local or remote host on which TCP, TLS or UDP Sockets should connect | | networkPort| the default port on which TCP, TLS, or UDP sockets should connect | -| encoding | the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : ` ascii` ` utf8 ` ` utf16le` ` ucs2` ` base64` ` hex ` . +| encoding | the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : ` ascii` ` utf8 ` ` utf16le` ` ucs2` ` base64` ` hex ` . | | rawBuffer| if true, data will be sent and received as a raw node ` Buffer ` __NOT__ an ` Object ` as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++ | | sync | synchronous requests. Clients will not send new requests until the server answers. | | silent | turn on/off logging default is false which means logging is on | +| logInColor | turn on/off util.inspect colors for ipc.log | +| logDepth | set the depth for util.inspect during ipc.log | | maxConnections| this is the max number of connections allowed to a socket. It is currently only being set on Unix Sockets. Other Socket types are using the system defaults. | | retry | this is the time in milliseconds a client will wait before trying to reconnect to a server if the connection is lost. This does not effect UDP sockets since they do not have a client server relationship like Unix Sockets and TCP Sockets. | | maxRetries | if set, it represents the maximum number of retries after each disconnect before giving up and completely killing a specific connection | @@ -123,37 +131,14 @@ These methods are available in the IPC Scope. `ipc.log(a,b,c,d,e...);` -ipc.log will accept any number of arguments and if `ipc.config.silent` is not set, it will concat them all with a sincle space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance. +ipc.log will accept any number of arguments and if `ipc.config.silent` is not set, it will concat them all with a single space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc.config.silent is set ` true `. That way if you leave your logging in place it should have almost no effect on performance. -The log also supports [colors](https://github.com/Marak/colors.js) implementation. All of the available styles are supported and the theme styles are as follows : +The log also uses util.inspect You can control if it should log in color as well as the log depth via ` ipc.config ` ```javascript - { - good : 'green', - notice : 'yellow', - warn : 'red', - error : 'redBG', - debug : 'magenta', - variable: 'cyan', - data : 'blue' - } - -``` - -You can override any of these settings by requireing colors and setting the theme as follows : - -```javascript - - var colors=require('colors'); - - colors.setTheme( - { - good : 'zebra', - notice : 'redBG', - ... - } - ); + ipc.config.logInColor=true; //default + ipc.config.logDepth=5; //default ``` @@ -474,6 +459,38 @@ or specifying everything UDP |***your event type***|***your event data***|triggered when a JSON message is received. The event name will be the type string from your message and the param will be the data object from your message eg : ` { type:'myEvent',data:{a:1}} ` | |||| +### Multiple IPC Instances + +Sometimes you might need explicit and independent instances of node-ipc. Just for such scenarios we have exposed the core IPC class on the IPC singleton. + +```javascript + + const RawIPC=require('node-ipc').IPC; + const ipc=new RawIPC; + const someOtherExplicitIPC=new RawIPC; + + + //OR + + const ipc=require('node-ipc'); + const someOtherExplicitIPC=new ipc.IPC; + + + //setting explicit configs + + //keep one silent and the other verbose + ipc.config.silent=true; + someOtherExplicitIPC.config.silent=true; + + //make one a raw binary and the other json based ipc + ipc.config.rawBuffer=false; + + someOtherExplicitIPC.config.rawBuffer=true; + someOtherExplicitIPC.config.encoding='hex'; + +``` + + ---- ### Basic Examples You can find [Advanced Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example) in the examples folder. In the examples you will find more complex demos including multi client examples. @@ -630,7 +647,7 @@ This is the most basic example which will work for both local and remote UDP Soc ``` #### Raw Buffer or Binary Sockets -Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is ***slightly*** different. +Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is ***slightly*** different. These may come in handy if working with embedded systems or C / C++ processes. You can even make sure to match C or C++ string typing. When setting up a rawBuffer socket you must specify it as such : @@ -669,6 +686,9 @@ emit byte array buffer : ```javascript + //hex encoding may work best for this. + ipc.config.encoding='hex'; + //server ipc.server.emit( socket, @@ -682,10 +702,12 @@ emit byte array buffer : ``` -emit hex array buffer : +emit binary or hex array buffer, this is best for real time data transfer, especially whan connecting to C or C++ processes, or embedded systems : ```javascript + ipc.config.encoding='hex'; + //server ipc.server.emit( socket, @@ -699,5 +721,49 @@ emit hex array buffer : ``` +Writing explicit buffers, int types, doubles, floats etc. as well as big endian and little endian data to raw buffer nostly valuable when connecting to C or C++ processes, or embedded systems (see more detailed info on buffers as well as UInt, Int, double etc. here)[https://nodejs.org/api/buffer.html]: + +```javascript + + ipc.config.encoding='hex'; + + //make a 6 byte buffer for example + const myBuffer=new Buffer(6).fill(0); + + //fill the first 2 bytes with a 16 bit (2 byte) short unsigned int + + //write a UInt16 (2 byte or short) as Big Endian + myBuffer.writeUInt16BE( + 2, //value to write + 0 //offset in bytes + ); + //OR + myBuffer.writeUInt16LE(0x2,0); + //OR + myBuffer.writeUInt16LE(0x02,0); + + //fill the remaining 4 bytes with a 32 bit (4 byte) long unsigned int + + //write a UInt32 (4 byte or long) as Big Endian + myBuffer.writeUInt32BE( + 16772812, //value to write + 2 //offset in bytes + ); + //OR + myBuffer.writeUInt32BE(0xffeecc,0) + + //server + ipc.server.emit( + socket, + myBuffer + ); + + //client + ipc.server.emit( + myBuffer + ); + +``` + #### Licensed under DBAD license See the [DBAD license](https://github.com/philsturgeon/dbad) in your language or our [licence.md](https://github.com/RIAEvangelist/node-phidget-API/blob/master/license.md) file. diff --git a/dao/client.js b/dao/client.js index 261c1ce..f1e0f08 100644 --- a/dao/client.js +++ b/dao/client.js @@ -25,14 +25,14 @@ function init(config,log){ } function emit(type,data){ - this.log('dispatching event to '.debug, (this.id).variable, this.path.variable,' : ', type.data,',', data); + this.log('dispatching event to ', this.id, this.path, ' : ', type, ',', data); let message=new Message; message.type=type; message.data=data; if(this.config.rawBuffer){ - message=new Buffer(type,this.encoding); + message=new Buffer(type,this.config.encoding); }else{ message=eventParser.format(message); } @@ -48,7 +48,7 @@ function emit(type,data){ } function syncEmit(message){ - this.log('dispatching event to '.debug, (this.id).variable, this.path.variable,' : ', message.data); + this.log('dispatching event to ', this.id, this.path, ' : ', message); this.socket.write(message); } @@ -56,14 +56,14 @@ function connect(){ //init client object for scope persistance especially inside of socket events. let client=this; - client.log('requested connection to '.debug, client.id.variable, client.path.variable); + client.log('requested connection to ', client.id, client.path); if(!this.path){ - client.log('\n\n######\nerror: '.error, client.id .info,' client has not specified socket path it wishes to connect to.'.error); + client.log('\n\n######\nerror: ', client.id ,' client has not specified socket path it wishes to connect to.'); return; } if(!client.port){ - client.log('Connecting client on Unix Socket :'.debug, client.path.variable); + client.log('Connecting client on Unix Socket :', client.path); let path = client.path; @@ -79,7 +79,7 @@ function connect(){ ); }else{ if(!client.config.tls){ - client.log('Connecting client via TCP to'.debug, client.path.variable ,client.port); + client.log('Connecting client via TCP to', client.path ,client.port); client.socket = net.connect( { port:client.port, @@ -87,7 +87,7 @@ function connect(){ } ); }else{ - client.log('Connecting client via TLS to'.debug, client.path.variable ,client.port,client.config.tls); + client.log('Connecting client via TLS to', client.path ,client.port,client.config.tls); if(client.config.tls.private){ client.config.tls.key=fs.readFileSync(client.config.tls.private); } @@ -120,7 +120,7 @@ function connect(){ client.socket.on( 'error', function(err){ - client.log('\n\n######\nerror: '.error, err); + client.log('\n\n######\nerror: ', err); client.trigger('error', err); } @@ -138,8 +138,8 @@ function connect(){ client.socket.on( 'close', function connectionClosed(){ - client.log('connection closed'.notice ,client.id.variable , client.path.variable, - `${client.retriesRemaining} tries remaining of ${client.config.maxRetries}` + client.log('connection closed' ,client.id , client.path, + client.retriesRemaining, 'tries remaining of', client.config.maxRetries ); if( @@ -148,8 +148,8 @@ function connect(){ ){ client.trigger('disconnect'); client.log( - (client.config.id).variable, - 'exceeded connection rety amount of'.warn, + (client.config.id), + 'exceeded connection rety amount of', ' or stopRetrying flag set.' ); @@ -186,11 +186,11 @@ function connect(){ client.socket.on( 'data', function(data) { - client.log('## recieved events ##'.rainbow); + client.log('## recieved events ##'); if(client.config.rawBuffer){ client.trigger( 'data', - new Buffer(data,this.encoding) + new Buffer(data,client.config.encoding) ); if(!client.config.sync){ return; @@ -207,7 +207,7 @@ function connect(){ data=(this.ipcBuffer+=data); if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){ - client.log('Implementing larger buffer for this socket message. You may want to consider smaller messages'.notice); + client.log('Messages are large, You may want to consider smaller messages.'); return; } @@ -219,7 +219,7 @@ function connect(){ let message=new Message; message.load(events[i]); - client.log('detected event of type '.debug, message.type.data, message.data); + client.log('detected event', message.type, message.data); client.trigger( message.type, message.data diff --git a/dao/socketServer.js b/dao/socketServer.js index f91d5b0..9b5124b 100644 --- a/dao/socketServer.js +++ b/dao/socketServer.js @@ -9,14 +9,15 @@ const net = require('net'), Message = require('js-message'); function emit(socket, type, data){ - this.log('dispatching event to socket'.debug, ' : ', type.data, data); + this.log('dispatching event to socket', ' : ', type, data); let message=new Message; message.type=type; message.data=data; if(this.config.rawBuffer){ - message=new Buffer(type,this.encoding); + console.log(this.config.encoding) + message=new Buffer(type,this.config.encoding); }else{ message=eventParser.format(message); } @@ -40,13 +41,13 @@ function emit(socket, type, data){ } function broadcast(type,data){ - this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data); + this.log('broadcasting event to all known sockets listening to ', this.path,' : ', ((this.port)?this.port:''), type, data); let message=new Message; message.type=type; message.data=data; if(this.config.rawBuffer){ - message=new Buffer(type,this.encoding); + message=new Buffer(type,this.config.encoding); }else{ message=eventParser.format(message); } @@ -85,7 +86,7 @@ function init(path,config,log,port){ }, start : function start(){ if(!this.path){ - server.log('Socket Server Path not specified, refusing to start'.warn); + server.log('Socket Server Path not specified, refusing to start'); return; } @@ -93,8 +94,8 @@ function init(path,config,log,port){ this.path, function () { server.log( - 'starting server on '.debug,server.path.variable, - ((server.port)?`:${server.port}`:'').variable + 'starting server on ',server.path, + ((server.port)?`:${server.port}`:'') ); if(!server.udp4 && !server.udp6){ @@ -103,7 +104,7 @@ function init(path,config,log,port){ serverCreated ); }else{ - server.log('starting TLS server'.debug,server.config.tls); + server.log('starting TLS server',server.config.tls); if(server.config.tls.private){ server.config.tls.key=fs.readFileSync(server.config.tls.private); }else{ @@ -144,7 +145,7 @@ function init(path,config,log,port){ socket.address, function(err, bytes) { if(err){ - server.log('error writing data to socket'.warn,err); + server.log('error writing data to socket',err); server.trigger( 'error', function(err){ @@ -171,7 +172,7 @@ function init(path,config,log,port){ server.server.on( 'error', function(err){ - server.log('server error'.warn,err); + server.log('server error',err); server.trigger( 'error', @@ -189,7 +190,7 @@ function init(path,config,log,port){ socket.setEncoding(server.config.encoding); } - server.log('## socket connection to server detected ##'.rainbow); + server.log('## socket connection to server detected ##'); socket.on( 'close', function(socket){ @@ -203,7 +204,7 @@ function init(path,config,log,port){ socket.on( 'error', function(err){ - server.log('server socket error'.warn,err); + server.log('server socket error',err); server.trigger('error',err); } @@ -214,7 +215,7 @@ function init(path,config,log,port){ function(data,UDPSocket){ let sock=((server.udp4 || server.udp6)? UDPSocket : socket); if(server.config.rawBuffer){ - data=new Buffer(data,this.encoding); + data=new Buffer(data,server.config.encoding); server.trigger( 'data', data, @@ -230,7 +231,7 @@ function init(path,config,log,port){ data=(this.ipcBuffer+=data); if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){ - server.log('Implementing larger buffer for this socket message. You may want to consider smaller messages'.notice); + server.log('Messages are large, You may want to consider smaller messages.'); return; } @@ -242,12 +243,12 @@ function init(path,config,log,port){ let message=new Message; message.load(data.shift()); - server.log('received event of : '.debug,message.type.data,message.data); + server.log('received event of : ',message.type,message.data); if(message.data.id){ sock.id=message.data.id; } - + server.trigger( message.type, message.data, @@ -264,11 +265,11 @@ function init(path,config,log,port){ return; } - server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port); + server.log('Received UDP message from ', rinfo.address, rinfo.port); let data; if(server.config.rawSocket){ - data=new Buffer(msg,this.encoding); + data=new Buffer(msg,server.config.encoding); }else{ data=msg.toString(); } @@ -291,7 +292,7 @@ function init(path,config,log,port){ } if(!port){ - server.log('starting server as'.debug, 'Unix || Windows Socket'.variable); + server.log('starting server as', 'Unix || Windows Socket'); if (process.platform ==='win32'){ server.path = server.path.replace(/^\//, ''); server.path = server.path.replace(/\//g, '-'); @@ -307,7 +308,7 @@ function init(path,config,log,port){ } if(!server.udp4 && !server.udp6){ - server.log('starting server as'.debug, (server.config.tls?'TLS':'TCP').variable); + server.log('starting server as', (server.config.tls?'TLS':'TCP')); server.server.listen( server.port, server.path, @@ -316,7 +317,7 @@ function init(path,config,log,port){ return; } - server.log('starting server as'.debug,((server.udp4)? 'udp4':'udp6').variable); + server.log('starting server as',((server.udp4)? 'udp4':'udp6')); server.server.bind( server.port, server.path @@ -352,7 +353,7 @@ function init(path,config,log,port){ destroyedSocketId=socket.id; } - server.log('socket disconnected'.notice,destroyedSocketId.toString().variable); + server.log('socket disconnected',destroyedSocketId.toString()); if(socket && socket.destroy){ socket.destroy(); diff --git a/entities/Defaults.js b/entities/Defaults.js index 9a69a7d..fb016cb 100644 --- a/entities/Defaults.js +++ b/entities/Defaults.js @@ -56,6 +56,16 @@ class Defaults{ writable:true, value:false }, + logDepth:{ + enumerable:true, + writable:true, + value:5 + }, + logInColor:{ + enumerable:true, + writable:true, + value:true + }, maxConnections : { enumerable:true, writable:true, diff --git a/entities/LogColors.js b/entities/LogColors.js deleted file mode 100644 index 92412ae..0000000 --- a/entities/LogColors.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -class LogColors{ - constructor(){ - this.good='green'; - this.notice='yellow'; - this.warn='red'; - this.error='redBG'; - this.debug='magenta'; - this.variable='cyan'; - this.data='blue'; - } -} - -module.exports=LogColors; diff --git a/example/TCPSocket/Multi-Client-Broadcast/goodbye-client.js b/example/TCPSocket/Multi-Client-Broadcast/goodbye-client.js index 14de4cc..9d5ce05 100644 --- a/example/TCPSocket/Multi-Client-Broadcast/goodbye-client.js +++ b/example/TCPSocket/Multi-Client-Broadcast/goodbye-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -17,7 +17,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -30,13 +30,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/TCPSocket/Multi-Client-Broadcast/hello-client.js b/example/TCPSocket/Multi-Client-Broadcast/hello-client.js index 5f57d20..7413633 100644 --- a/example/TCPSocket/Multi-Client-Broadcast/hello-client.js +++ b/example/TCPSocket/Multi-Client-Broadcast/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -17,7 +17,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -30,19 +30,19 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'app.message', function(data){ - ipc.log('got a message from world : '.debug, data.message); + ipc.log('got a message from world : ', data.message); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/TCPSocket/Multi-Client-Broadcast/world-server.js b/example/TCPSocket/Multi-Client-Broadcast/world-server.js index a1dc9f4..2bef447 100644 --- a/example/TCPSocket/Multi-Client-Broadcast/world-server.js +++ b/example/TCPSocket/Multi-Client-Broadcast/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -20,7 +20,7 @@ ipc.serveNet( ipc.server.on( 'app.message', function(data,socket){ - ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); + ipc.log('got a message from', (data.id), (data.message)); messages[data.id]=true; ipc.server.emit( socket, @@ -32,7 +32,7 @@ ipc.serveNet( ); if(messages.hello && messages.goodbye){ - ipc.log('got all required events, telling clients to kill connection'.good); + ipc.log('got all required events, telling clients to kill connection'); ipc.server.broadcast( 'kill.connection', { diff --git a/example/TCPSocket/basic/hello-client.js b/example/TCPSocket/basic/hello-client.js index 491a64d..d27f0e9 100644 --- a/example/TCPSocket/basic/hello-client.js +++ b/example/TCPSocket/basic/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'message', 'hello' @@ -26,13 +26,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TCPSocket/basic/world-server.js b/example/TCPSocket/basic/world-server.js index 19ee193..81004c6 100644 --- a/example/TCPSocket/basic/world-server.js +++ b/example/TCPSocket/basic/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); ipc.server.emit( socket, 'message', @@ -37,7 +37,7 @@ ipc.serveNet( ipc.server.on( 'error', function(err){ - ipc.log('Got an ERROR!'.warn,err); + ipc.log('Got an ERROR!',err); } ); diff --git a/example/TCPSocket/basicSync/hello-client.js b/example/TCPSocket/basicSync/hello-client.js index 9f69792..2924150 100644 --- a/example/TCPSocket/basicSync/hello-client.js +++ b/example/TCPSocket/basicSync/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -17,7 +17,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); //queue up a bunch of requests to be sent synchronously for(var i=0; i<10; i++){ @@ -31,13 +31,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data,'\n\n'); + ipc.log('got a message from world : ', data,'\n\n'); } ); } diff --git a/example/TCPSocket/basicSync/world-server.js b/example/TCPSocket/basicSync/world-server.js index 388dd05..3e817da 100644 --- a/example/TCPSocket/basicSync/world-server.js +++ b/example/TCPSocket/basicSync/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); //fake some synch procedural code setTimeout( function(){ diff --git a/example/TCPSocket/rawBuffer/hello-client.js b/example/TCPSocket/rawBuffer/hello-client.js index 245359e..b6ac81f 100644 --- a/example/TCPSocket/rawBuffer/hello-client.js +++ b/example/TCPSocket/rawBuffer/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -18,7 +18,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'hello' ); @@ -28,7 +28,7 @@ ipc.connectToNet( ipc.of.world.on( 'data', function(data){ - ipc.log('got a message from world : '.debug, data,data.toString()); + ipc.log('got a message from world : ', data,data.toString()); } ); } diff --git a/example/TCPSocket/rawBuffer/world.server.js b/example/TCPSocket/rawBuffer/world.server.js index ac05e46..5da4de4 100644 --- a/example/TCPSocket/rawBuffer/world.server.js +++ b/example/TCPSocket/rawBuffer/world.server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -27,7 +27,7 @@ ipc.serveNet( ipc.server.on( 'data', function(data,socket){ - ipc.log('got a message'.debug, data,data.toString()); + ipc.log('got a message', data,data.toString()); ipc.server.emit( socket, 'goodbye' diff --git a/example/TLSSocket/Multi-Client-Broadcast-basic/goodbye-client.js b/example/TLSSocket/Multi-Client-Broadcast-basic/goodbye-client.js index 2d8dd43..508702d 100644 --- a/example/TLSSocket/Multi-Client-Broadcast-basic/goodbye-client.js +++ b/example/TLSSocket/Multi-Client-Broadcast-basic/goodbye-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -20,7 +20,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -33,13 +33,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/TLSSocket/Multi-Client-Broadcast-basic/hello-client.js b/example/TLSSocket/Multi-Client-Broadcast-basic/hello-client.js index 79c27a5..16fd21f 100644 --- a/example/TLSSocket/Multi-Client-Broadcast-basic/hello-client.js +++ b/example/TLSSocket/Multi-Client-Broadcast-basic/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -20,7 +20,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -33,19 +33,19 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'app.message', function(data){ - ipc.log('got a message from world : '.debug, data.message); + ipc.log('got a message from world : ', data.message); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js index dd60c9c..0c52c26 100644 --- a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js +++ b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -24,7 +24,7 @@ ipc.serveNet( ipc.server.on( 'app.message', function(data,socket){ - ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); + ipc.log('got a message from', (data.id), (data.message)); messages[data.id]=true; ipc.server.emit( socket, @@ -36,7 +36,7 @@ ipc.serveNet( ); if(messages.hello && messages.goodbye){ - ipc.log('got all required events, telling clients to kill connection'.good); + ipc.log('got all required events, telling clients to kill connection'); ipc.server.broadcast( 'kill.connection', { diff --git a/example/TLSSocket/basic-local-only/hello-client.js b/example/TLSSocket/basic-local-only/hello-client.js index 04ab330..1577156 100644 --- a/example/TLSSocket/basic-local-only/hello-client.js +++ b/example/TLSSocket/basic-local-only/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -19,7 +19,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'message', 'hello' @@ -29,13 +29,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TLSSocket/basic-local-only/world-server.js b/example/TLSSocket/basic-local-only/world-server.js index 9b1a3ea..3cbcd8e 100644 --- a/example/TLSSocket/basic-local-only/world-server.js +++ b/example/TLSSocket/basic-local-only/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -19,7 +19,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); ipc.server.emit( socket, 'message', diff --git a/example/TLSSocket/basic-more-secure/hello-client.js b/example/TLSSocket/basic-more-secure/hello-client.js index bf43504..bda3eb7 100644 --- a/example/TLSSocket/basic-more-secure/hello-client.js +++ b/example/TLSSocket/basic-more-secure/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -24,7 +24,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'message', 'hello' @@ -34,13 +34,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TLSSocket/basic-more-secure/world-server.js b/example/TLSSocket/basic-more-secure/world-server.js index 4ce686a..56eee12 100644 --- a/example/TLSSocket/basic-more-secure/world-server.js +++ b/example/TLSSocket/basic-more-secure/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -25,7 +25,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); ipc.server.emit( socket, 'message', diff --git a/example/TLSSocket/basic-most-secure/hello-client.js b/example/TLSSocket/basic-most-secure/hello-client.js index 5256bce..26d5b1d 100644 --- a/example/TLSSocket/basic-most-secure/hello-client.js +++ b/example/TLSSocket/basic-most-secure/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -25,7 +25,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'message', 'hello' @@ -35,13 +35,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TLSSocket/basic-most-secure/world-server.js b/example/TLSSocket/basic-most-secure/world-server.js index 2d9c434..ee984a4 100644 --- a/example/TLSSocket/basic-most-secure/world-server.js +++ b/example/TLSSocket/basic-most-secure/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -26,7 +26,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); ipc.server.emit( socket, 'message', diff --git a/example/TLSSocket/basic/hello-client.js b/example/TLSSocket/basic/hello-client.js index 04ab330..1577156 100644 --- a/example/TLSSocket/basic/hello-client.js +++ b/example/TLSSocket/basic/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -19,7 +19,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'message', 'hello' @@ -29,13 +29,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TLSSocket/basic/world-server.js b/example/TLSSocket/basic/world-server.js index 72c81c0..a52c360 100644 --- a/example/TLSSocket/basic/world-server.js +++ b/example/TLSSocket/basic/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -19,7 +19,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); ipc.server.emit( socket, 'message', diff --git a/example/TLSSocket/basicSync/hello-client.js b/example/TLSSocket/basicSync/hello-client.js index 84a490f..405db44 100644 --- a/example/TLSSocket/basicSync/hello-client.js +++ b/example/TLSSocket/basicSync/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -20,7 +20,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); //queue up a bunch of requests to be sent synchronously for(var i=0; i<10; i++){ @@ -34,13 +34,13 @@ ipc.connectToNet( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); } diff --git a/example/TLSSocket/basicSync/world-server.js b/example/TLSSocket/basicSync/world-server.js index 3282778..aec87c1 100644 --- a/example/TLSSocket/basicSync/world-server.js +++ b/example/TLSSocket/basicSync/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -20,7 +20,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message : '.debug, data); + ipc.log('got a message : ', data); setTimeout( function(){ ipc.server.emit( diff --git a/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js b/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js index 6b3f129..f0c66ad 100644 --- a/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js +++ b/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -28,7 +28,7 @@ ipc.connectToNet( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'hello' ); @@ -38,7 +38,7 @@ ipc.connectToNet( ipc.of.world.on( 'data', function(data){ - ipc.log('got a message from world : '.debug, data,data.toString()); + ipc.log('got a message from world : ', data,data.toString()); } ); } diff --git a/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js b/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js index ab5d9d9..f0d0b29 100644 --- a/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js +++ b/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -40,7 +40,7 @@ ipc.serveNet( ipc.server.on( 'data', function(data,socket){ - ipc.log('got a message'.debug, data,data.toString()); + ipc.log('got a message', data,data.toString()); ipc.server.emit( socket, 'goodbye' diff --git a/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js b/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js index 6056420..d98a7b0 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js +++ b/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js @@ -1,18 +1,18 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ - * + * * Since there is no client relationship - * with UDP sockets sockets are not kept + * with UDP sockets sockets are not kept * open. - * + * * This means the order sockets are opened * is important. - * - * Start World first. Then you can start + * + * Start World first. Then you can start * hello or goodbye in any order you * choose. - * + * * *************************************/ ipc.config.id = 'goodbye'; @@ -26,7 +26,7 @@ ipc.serveNet( 'message', function(data){ ipc.log('got Data'); - ipc.log('got a message from '.debug, data.id.variable ,' : '.debug, data.message.data); + ipc.log('got a message from ', data.id ,' : ', data.message); } ); ipc.server.emit( diff --git a/example/UDPSocket/Multi-Client-Broadcast/hello-client.js b/example/UDPSocket/Multi-Client-Broadcast/hello-client.js index 10ca453..ecc0b45 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/hello-client.js +++ b/example/UDPSocket/Multi-Client-Broadcast/hello-client.js @@ -1,20 +1,20 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ - * + * * Since there is no client relationship - * with UDP sockets sockets are not kept + * with UDP sockets sockets are not kept * open. - * + * * This means the order sockets are opened * is important. - * - * Start World first. Then you can start + * + * Start World first. Then you can start * hello or goodbye in any order you * choose. - * + * * *************************************/ - + ipc.config.id = 'hello'; ipc.config.retry= 1500; @@ -26,7 +26,7 @@ ipc.serveNet( 'message', function(data){ ipc.log('got Data'); - ipc.log('got a message from '.debug, data.id.variable ,' : '.debug, data.message.data); + ipc.log('got a message from ', data.id ,' : ', data.message); } ); ipc.server.emit( diff --git a/example/UDPSocket/Multi-Client-Broadcast/world-server.js b/example/UDPSocket/Multi-Client-Broadcast/world-server.js index 6f2ff98..97f9270 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/world-server.js +++ b/example/UDPSocket/Multi-Client-Broadcast/world-server.js @@ -1,18 +1,18 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ - * + * * Since there is no client relationship - * with UDP sockets sockets are not kept + * with UDP sockets sockets are not kept * open. - * + * * This means the order sockets are opened * is important. - * - * Start World first. Then you can start + * + * Start World first. Then you can start * hello or goodbye in any order you * choose. - * + * ***************************************/ ipc.config.id = 'world'; @@ -30,7 +30,7 @@ ipc.serveNet( ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message from '.debug, data.id.variable ,' : '.debug, data.message.data); + ipc.log('got a message from ', data.id ,' : ', data.message); messages[data.id]=true; ipc.server.emit( socket, @@ -40,9 +40,9 @@ ipc.serveNet( message : data.message+' world!' } ); - + if(messages.hello && messages.goodbye){ - ipc.log('got all required events, telling evryone how muchg I am loved!'.good); + ipc.log('got all required events, telling evryone how muchg I am loved!'); ipc.server.broadcast( 'message', { @@ -53,7 +53,7 @@ ipc.serveNet( } } ); - + console.log(ipc.server); } ); diff --git a/example/UDPSocket/basic/hello-client.js b/example/UDPSocket/basic/hello-client.js index 1d060d0..f731b1b 100644 --- a/example/UDPSocket/basic/hello-client.js +++ b/example/UDPSocket/basic/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -30,7 +30,7 @@ ipc.serveNet( 'message', function(data){ ipc.log('got Data'); - ipc.log('got a message from '.debug, data.id.variable ,' : '.debug, data.message.data); + ipc.log('got a message from ', data.id ,' : ', data.message); } ); ipc.server.emit( diff --git a/example/UDPSocket/basic/world-server.js b/example/UDPSocket/basic/world-server.js index 8946a0f..0f7aa45 100644 --- a/example/UDPSocket/basic/world-server.js +++ b/example/UDPSocket/basic/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -25,11 +25,10 @@ ipc.config.retry= 1500; ipc.serveNet( 'udp4', function(){ - console.log(123); ipc.server.on( 'message', function(data,socket){ - ipc.log('got a message from '.debug, data.id.variable ,' : '.debug, data.message.data); + ipc.log('got a message from ', data.id ,' : ', data.message); ipc.server.emit( socket, 'message', diff --git a/example/UDPSocket/rawBuffer/hello-client.js b/example/UDPSocket/rawBuffer/hello-client.js index 62f31ef..73cd13a 100644 --- a/example/UDPSocket/rawBuffer/hello-client.js +++ b/example/UDPSocket/rawBuffer/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -19,7 +19,7 @@ ipc.serveNet( ipc.server.on( 'data', function(data){ - ipc.log('got a message from world '.debug, data, data.toString()); + ipc.log('got a message from world ', data, data.toString()); } ); ipc.server.emit( diff --git a/example/UDPSocket/rawBuffer/world.server.js b/example/UDPSocket/rawBuffer/world.server.js index f430ca1..d0c34f7 100644 --- a/example/UDPSocket/rawBuffer/world.server.js +++ b/example/UDPSocket/rawBuffer/world.server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -30,7 +30,7 @@ ipc.serveNet( ipc.server.on( 'data', function(data,socket){ - ipc.log('got a message'.debug, data,data.toString()); + ipc.log('got a message', data,data.toString()); ipc.server.emit( socket, 'goodbye' diff --git a/example/rawBuffer/hello-client.js b/example/rawBuffer/hello-client.js new file mode 100644 index 0000000..f22ab53 --- /dev/null +++ b/example/rawBuffer/hello-client.js @@ -0,0 +1,43 @@ +'use strict'; + +const ipc=require('../../../node-ipc'); + +/***************************************\ + * + * You should start both hello and world + * then you will see them communicating. + * + * *************************************/ + +ipc.config.id = 'hello'; +ipc.config.retry= 1500; +ipc.config.rawBuffer=true; +ipc.config.encoding='hex'; + +ipc.connectTo( + 'world', + function(){ + ipc.of.world.on( + 'connect', + function(){ + //make a 6 byte buffer for example + const myBuffer=new Buffer(6).fill(0); + + myBuffer.writeUInt16BE(0x02,0); + myBuffer.writeUInt32BE(0xffeecc,2); + + ipc.log('## connected to world ##', ipc.config.delay); + ipc.of.world.emit( + myBuffer + ); + } + ); + + ipc.of.world.on( + 'data', + function(data){ + ipc.log('got a message from world : ', data); + } + ); + } +); diff --git a/example/rawBuffer/world.server.js b/example/rawBuffer/world.server.js new file mode 100644 index 0000000..f27a02c --- /dev/null +++ b/example/rawBuffer/world.server.js @@ -0,0 +1,40 @@ +const ipc=require('../../../node-ipc'); + +/***************************************\ + * + * You should start both hello and world + * then you will see them communicating. + * + * *************************************/ + +ipc.config.id = 'world'; +ipc.config.retry= 1500; +ipc.config.rawBuffer=true; +ipc.config.encoding='hex'; + +ipc.serve( + function(){ + ipc.server.on( + 'connect', + function(socket){ + ipc.server.emit( + socket, + [0xaa] + ); + } + ); + + ipc.server.on( + 'data', + function(data,socket){ + ipc.log('got a message', data); + ipc.server.emit( + socket, + [0x0d,0xee] + ); + } + ); + } +); + +ipc.server.start(); diff --git a/example/unixWindowsSocket/Multi-Client-Broadcast/goodbye-client.js b/example/unixWindowsSocket/Multi-Client-Broadcast/goodbye-client.js index 766ccde..57d455e 100644 --- a/example/unixWindowsSocket/Multi-Client-Broadcast/goodbye-client.js +++ b/example/unixWindowsSocket/Multi-Client-Broadcast/goodbye-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.connectTo( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -29,13 +29,13 @@ ipc.connectTo( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/unixWindowsSocket/Multi-Client-Broadcast/hello-client.js b/example/unixWindowsSocket/Multi-Client-Broadcast/hello-client.js index 2feb032..d556c46 100644 --- a/example/unixWindowsSocket/Multi-Client-Broadcast/hello-client.js +++ b/example/unixWindowsSocket/Multi-Client-Broadcast/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.connectTo( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -29,19 +29,19 @@ ipc.connectTo( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'app.message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); ipc.of.world.on( 'kill.connection', function(data){ - ipc.log('world requested kill.connection'.notice); + ipc.log('world requested kill.connection'); ipc.disconnect('world'); } ); diff --git a/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js b/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js index 7d9887a..69cfb31 100644 --- a/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js +++ b/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js @@ -1,10 +1,10 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ - * + * * You should start both hello and world * then you will see them communicating. - * + * * *************************************/ ipc.config.id = 'world'; @@ -20,7 +20,7 @@ ipc.serve( ipc.server.on( 'app.message', function(data,socket){ - ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); + ipc.log('got a message from', (data.id), (data.message)); messages[data.id]=true; ipc.server.emit( socket, @@ -30,9 +30,9 @@ ipc.serve( message : data.message+' world!' } ); - + if(messages.hello && messages.goodbye){ - ipc.log('got all required events, telling clients to kill connection'.good); + ipc.log('got all required events, telling clients to kill connection'); ipc.server.broadcast( 'kill.connection', { diff --git a/example/unixWindowsSocket/basic/hello-client.js b/example/unixWindowsSocket/basic/hello-client.js index 214f9e7..c6d87cb 100644 --- a/example/unixWindowsSocket/basic/hello-client.js +++ b/example/unixWindowsSocket/basic/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,7 +16,7 @@ ipc.connectTo( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'app.message', { @@ -29,13 +29,13 @@ ipc.connectTo( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'app.message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); diff --git a/example/unixWindowsSocket/basic/world-server.js b/example/unixWindowsSocket/basic/world-server.js index 1b0028a..6b30522 100644 --- a/example/unixWindowsSocket/basic/world-server.js +++ b/example/unixWindowsSocket/basic/world-server.js @@ -1,10 +1,10 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ - * + * * You should start both hello and world * then you will see them communicating. - * + * * *************************************/ ipc.config.id = 'world'; @@ -15,7 +15,6 @@ ipc.serve( ipc.server.on( 'app.message', function(data,socket){ - //ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); ipc.server.emit( socket, 'app.message', diff --git a/example/unixWindowsSocket/basicSync/hello-client.js b/example/unixWindowsSocket/basicSync/hello-client.js index cc192c6..3142677 100644 --- a/example/unixWindowsSocket/basicSync/hello-client.js +++ b/example/unixWindowsSocket/basicSync/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -17,7 +17,7 @@ ipc.connectTo( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); //queue up a bunch of requests to be sent synchronously for(var i=0; i<10; i++){ @@ -34,13 +34,13 @@ ipc.connectTo( ipc.of.world.on( 'disconnect', function(){ - ipc.log('disconnected from world'.notice); + ipc.log('disconnected from world'); } ); ipc.of.world.on( 'app.message', function(data){ - ipc.log('got a message from world : '.debug, data); + ipc.log('got a message from world : ', data); } ); diff --git a/example/unixWindowsSocket/basicSync/world-server.js b/example/unixWindowsSocket/basicSync/world-server.js index 0100630..c76e1bb 100644 --- a/example/unixWindowsSocket/basicSync/world-server.js +++ b/example/unixWindowsSocket/basicSync/world-server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -16,8 +16,6 @@ ipc.serve( ipc.server.on( 'app.message', function(data,socket){ - //ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); - setTimeout( function(){ ipc.server.emit( diff --git a/example/unixWindowsSocket/rawBuffer/hello-client.js b/example/unixWindowsSocket/rawBuffer/hello-client.js index 9781ba1..9c7042a 100644 --- a/example/unixWindowsSocket/rawBuffer/hello-client.js +++ b/example/unixWindowsSocket/rawBuffer/hello-client.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -18,7 +18,7 @@ ipc.connectTo( ipc.of.world.on( 'connect', function(){ - ipc.log('## connected to world ##'.rainbow, ipc.config.delay); + ipc.log('## connected to world ##', ipc.config.delay); ipc.of.world.emit( 'hello' ); @@ -28,7 +28,7 @@ ipc.connectTo( ipc.of.world.on( 'data', function(data){ - ipc.log('got a message from world : '.debug, data,data.toString()); + ipc.log('got a message from world : ', data,data.toString()); } ); } diff --git a/example/unixWindowsSocket/rawBuffer/world.server.js b/example/unixWindowsSocket/rawBuffer/world.server.js index db1b3f2..c3ed83c 100644 --- a/example/unixWindowsSocket/rawBuffer/world.server.js +++ b/example/unixWindowsSocket/rawBuffer/world.server.js @@ -1,4 +1,4 @@ -var ipc=require('../../../node-ipc'); +const ipc=require('../../../node-ipc'); /***************************************\ * @@ -27,7 +27,7 @@ ipc.serve( ipc.server.on( 'data', function(data,socket){ - ipc.log('got a message'.debug, data,data.toString()); + ipc.log('got a message', data,data.toString()); ipc.server.emit( socket, 'goodbye' diff --git a/node-ipc.js b/node-ipc.js index c070198..1c63360 100644 --- a/node-ipc.js +++ b/node-ipc.js @@ -1,8 +1,6 @@ 'use strict'; -const colors = require('colors'), - LogColors = require('./entities/LogColors.js'), - IPC = require('./services/IPC.js'); +const IPC = require('./services/IPC.js'); class IPCModule extends IPC{ constructor(){ @@ -20,7 +18,4 @@ class IPCModule extends IPC{ } } - -colors.setTheme(new LogColors); - module.exports=new IPCModule; diff --git a/package.json b/package.json index cb2862d..d609e06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-ipc", - "version": "6.0.2", + "version": "7.0.0", "description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.", "main": "node-ipc.js", "directories": { diff --git a/services/IPC.js b/services/IPC.js index 4d5a82d..91f9aed 100644 --- a/services/IPC.js +++ b/services/IPC.js @@ -66,14 +66,20 @@ function log(){ return; } - let args=Array.prototype.slice.call(arguments); + const args=Array.prototype.slice.call(arguments); for(let i=0, count=args.length; i