diff --git a/README.md b/README.md index c9bd373..0a4eab0 100644 --- a/README.md +++ b/README.md @@ -450,8 +450,8 @@ or specifying everything UDP |connect||triggered when socket connected| |disconnect||triggered when socket disconnected| |destroy||triggered when socket has been totally destroyed, no further auto retries will happen and all references are gone.| -|||| -|||| +|data|buffer|triggered when ipc.config.rawBuffer is true and a message is received.| +|***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}} ` | |||| ---- @@ -476,7 +476,8 @@ The server is the process keeping a socket for IPC open. Multiple sockets can co ipc.log('got a message : '.debug, data); ipc.server.emit( socket, - 'message', + 'message', //this can be anything you want so long as + //your client knows. data+' world!' ); } @@ -506,7 +507,7 @@ The client connects to the servers socket for Inter Process Communication. The s function(){ ipc.log('## connected to world ##'.rainbow, ipc.config.delay); ipc.of.world.emit( - 'message', + 'message', //any event or message type your server listens for 'hello' ) } @@ -518,7 +519,7 @@ The client connects to the servers socket for Inter Process Communication. The s } ); ipc.of.world.on( - 'message', + 'message', //any event or message type your server listens for function(data){ ipc.log('got a message from world : '.debug, data); } @@ -567,8 +568,6 @@ This is the most basic example which will work for both local and remote UDP Soc } ); - ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; - ipc.server.start(); ``` @@ -606,8 +605,6 @@ This is the most basic example which will work for both local and remote UDP Soc } ); - ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; - ipc.server.start(); ``` diff --git a/example/TCPSocket/Multi-Client-Broadcast/world-server.js b/example/TCPSocket/Multi-Client-Broadcast/world-server.js index a550299..5d0844f 100644 --- a/example/TCPSocket/Multi-Client-Broadcast/world-server.js +++ b/example/TCPSocket/Multi-Client-Broadcast/world-server.js @@ -1,10 +1,10 @@ var ipc=require('../../../node-ipc'); /***************************************\ - * + * * You should start both hello and world * then you will see them communicating. - * + * * *************************************/ ipc.config.id = 'world'; @@ -30,7 +30,7 @@ ipc.serveNet( message : data.message+' world!' } ); - + if(messages.hello && messages.goodbye){ ipc.log('got all required events, telling clients to kill connection'.good); ipc.server.broadcast( @@ -45,7 +45,7 @@ ipc.serveNet( } ); -ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.'; -ipc.server.define.broadcast['kill.connection']='This event is a command to kill connection to this server, the data object will contain the id of this server incase the client needs it'; + + ipc.server.start(); diff --git a/example/TCPSocket/basic/world-server.js b/example/TCPSocket/basic/world-server.js index 3cc0d56..8176d61 100644 --- a/example/TCPSocket/basic/world-server.js +++ b/example/TCPSocket/basic/world-server.js @@ -1,10 +1,10 @@ var ipc=require('../../../node-ipc'); /***************************************\ - * + * * You should start both hello and world * then you will see them communicating. - * + * * *************************************/ ipc.config.id = 'world'; @@ -23,7 +23,7 @@ ipc.serveNet( ); } ); - + ipc.server.on( 'socket.disconnected', function(data,socket){ @@ -33,6 +33,4 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; - -ipc.server.start(); \ No newline at end of file +ipc.server.start(); diff --git a/example/TCPSocket/basicSync/world-server.js b/example/TCPSocket/basicSync/world-server.js index 347858d..4ea38d5 100644 --- a/example/TCPSocket/basicSync/world-server.js +++ b/example/TCPSocket/basicSync/world-server.js @@ -9,7 +9,7 @@ var ipc=require('../../../node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; -ipc.config.sync = true; //sync servers do not bradcast defined events +ipc.config.sync = true; ipc.serveNet( function(){ @@ -40,6 +40,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js index 7c8a9b6..7442d85 100644 --- a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js +++ b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js @@ -49,7 +49,7 @@ ipc.serveNet( } ); -ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.'; -ipc.server.define.broadcast['kill.connection']='This event is a command to kill connection to this server, the data object will contain the id of this server incase the client needs it'; + + ipc.server.start(); diff --git a/example/TLSSocket/basic-local-only/world-server.js b/example/TLSSocket/basic-local-only/world-server.js index b7b93a2..3a6ea04 100644 --- a/example/TLSSocket/basic-local-only/world-server.js +++ b/example/TLSSocket/basic-local-only/world-server.js @@ -37,6 +37,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/TLSSocket/basic-more-secure/world-server.js b/example/TLSSocket/basic-more-secure/world-server.js index 1120bca..a893487 100644 --- a/example/TLSSocket/basic-more-secure/world-server.js +++ b/example/TLSSocket/basic-more-secure/world-server.js @@ -43,6 +43,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/TLSSocket/basic-most-secure/world-server.js b/example/TLSSocket/basic-most-secure/world-server.js index 49f6b09..e44b4c9 100644 --- a/example/TLSSocket/basic-most-secure/world-server.js +++ b/example/TLSSocket/basic-most-secure/world-server.js @@ -44,6 +44,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/TLSSocket/basic/world-server.js b/example/TLSSocket/basic/world-server.js index 7af34c3..a78da8a 100644 --- a/example/TLSSocket/basic/world-server.js +++ b/example/TLSSocket/basic/world-server.js @@ -37,6 +37,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/TLSSocket/basicSync/world-server.js b/example/TLSSocket/basicSync/world-server.js index 11767b6..8ae2325 100644 --- a/example/TLSSocket/basicSync/world-server.js +++ b/example/TLSSocket/basicSync/world-server.js @@ -43,6 +43,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js b/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js index 27697a7..1ebb98b 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js +++ b/example/UDPSocket/Multi-Client-Broadcast/goodbye-client.js @@ -43,6 +43,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); \ No newline at end of file diff --git a/example/UDPSocket/Multi-Client-Broadcast/hello-client.js b/example/UDPSocket/Multi-Client-Broadcast/hello-client.js index 9408740..7dda703 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/hello-client.js +++ b/example/UDPSocket/Multi-Client-Broadcast/hello-client.js @@ -43,6 +43,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); \ No newline at end of file diff --git a/example/UDPSocket/Multi-Client-Broadcast/world-server.js b/example/UDPSocket/Multi-Client-Broadcast/world-server.js index 78b8c19..53c9a4a 100644 --- a/example/UDPSocket/Multi-Client-Broadcast/world-server.js +++ b/example/UDPSocket/Multi-Client-Broadcast/world-server.js @@ -58,6 +58,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); \ No newline at end of file diff --git a/example/UDPSocket/basic/hello-client.js b/example/UDPSocket/basic/hello-client.js index 88e33fb..cfe41d7 100644 --- a/example/UDPSocket/basic/hello-client.js +++ b/example/UDPSocket/basic/hello-client.js @@ -47,6 +47,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); \ No newline at end of file diff --git a/example/UDPSocket/basic/world-server.js b/example/UDPSocket/basic/world-server.js index fec2e6e..75d46a9 100644 --- a/example/UDPSocket/basic/world-server.js +++ b/example/UDPSocket/basic/world-server.js @@ -43,6 +43,6 @@ ipc.serveNet( } ); -ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; + ipc.server.start(); \ No newline at end of file diff --git a/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js b/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js index b956925..af3dce8 100644 --- a/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js +++ b/example/unixWindowsSocket/Multi-Client-Broadcast/world-server.js @@ -45,7 +45,7 @@ ipc.serve( } ); -ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.'; -ipc.server.define.broadcast['kill.connection']='This event is a command to kill connection to this server, the data object will contain the id of this server incase the client needs it'; + + ipc.server.start(); diff --git a/example/unixWindowsSocket/basic/world-server.js b/example/unixWindowsSocket/basic/world-server.js index 7ad96e9..1919d5b 100644 --- a/example/unixWindowsSocket/basic/world-server.js +++ b/example/unixWindowsSocket/basic/world-server.js @@ -29,6 +29,6 @@ ipc.serve( } ); -ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/example/unixWindowsSocket/basicSync/world-server.js b/example/unixWindowsSocket/basicSync/world-server.js index 42a0bf6..da24ccf 100644 --- a/example/unixWindowsSocket/basicSync/world-server.js +++ b/example/unixWindowsSocket/basicSync/world-server.js @@ -36,6 +36,6 @@ ipc.serve( } ); -ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.'; + ipc.server.start(); diff --git a/node-ipc.js b/node-ipc.js index ab3a7d4..826d0ed 100644 --- a/node-ipc.js +++ b/node-ipc.js @@ -31,7 +31,7 @@ var defaults={ id : os.hostname(), encoding : 'utf8', rawBuffer : false, - sync : false, + sync : false, silent : false, maxConnections : 100, retry : 500,