2014-02-22 01:13:31 -08:00
|
|
|
var ipc=require('../../../node-ipc');
|
|
|
|
|
|
|
|
/***************************************\
|
2015-12-10 02:29:15 -08:00
|
|
|
*
|
2014-02-22 01:13:31 -08:00
|
|
|
* You should start both hello and world
|
|
|
|
* then you will see them communicating.
|
2015-12-10 02:29:15 -08:00
|
|
|
*
|
2014-02-22 01:13:31 -08:00
|
|
|
* *************************************/
|
|
|
|
|
2016-01-10 04:18:14 -08:00
|
|
|
ipc.config.id = 'world';
|
2014-02-22 01:13:31 -08:00
|
|
|
ipc.config.retry= 1500;
|
2016-01-04 01:10:58 -08:00
|
|
|
ipc.config.maxConnections=1;
|
2014-02-22 01:13:31 -08:00
|
|
|
|
2014-02-26 14:04:09 -08:00
|
|
|
ipc.serveNet(
|
2014-02-22 01:13:31 -08:00
|
|
|
function(){
|
|
|
|
ipc.server.on(
|
|
|
|
'message',
|
|
|
|
function(data,socket){
|
|
|
|
ipc.log('got a message : '.debug, data);
|
2014-02-27 13:26:08 -08:00
|
|
|
ipc.server.emit(
|
|
|
|
socket,
|
2014-02-22 01:13:31 -08:00
|
|
|
'message',
|
|
|
|
data+' world!'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2015-12-10 02:29:15 -08:00
|
|
|
|
2014-08-27 20:41:12 -07:00
|
|
|
ipc.server.on(
|
|
|
|
'socket.disconnected',
|
|
|
|
function(data,socket){
|
2016-01-10 04:18:14 -08:00
|
|
|
console.log(arguments);
|
2014-08-27 20:41:12 -07:00
|
|
|
}
|
|
|
|
);
|
2014-02-22 01:13:31 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-01-04 01:00:08 -08:00
|
|
|
ipc.server.on(
|
|
|
|
'error',
|
|
|
|
function(err){
|
2016-01-10 04:18:14 -08:00
|
|
|
ipc.log('Got an ERROR!'.warn,err);
|
2016-01-04 01:00:08 -08:00
|
|
|
}
|
2016-01-10 04:18:14 -08:00
|
|
|
);
|
2016-01-04 01:00:08 -08:00
|
|
|
|
2015-12-10 02:29:15 -08:00
|
|
|
ipc.server.start();
|