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