node-ipc/example/unixWindowsSocket/basic/hello-client.js

45 lines
1 KiB
JavaScript
Raw Normal View History

const ipc=require('../../../node-ipc');
2014-02-22 01:13:31 -08:00
/***************************************\
*
2014-02-22 01:13:31 -08:00
* You should start both hello and world
* then you will see them communicating.
*
2014-02-22 01:13:31 -08:00
* *************************************/
2016-01-10 04:18:14 -08:00
ipc.config.id = 'hello';
2014-08-31 10:56:53 -07:00
ipc.config.retry = 1000;
2014-02-22 01:13:31 -08:00
ipc.connectTo(
'world',
function(){
ipc.of.world.on(
'connect',
function(){
ipc.log('## connected to world ##', ipc.config.delay);
2014-02-22 01:13:31 -08:00
ipc.of.world.emit(
'app.message',
{
2014-09-02 23:25:35 -07:00
id : ipc.config.id,
message : 'hello'
}
2016-01-10 04:18:14 -08:00
);
2014-02-22 01:13:31 -08:00
}
);
ipc.of.world.on(
'disconnect',
function(){
ipc.log('disconnected from world');
2014-02-22 01:13:31 -08:00
}
);
ipc.of.world.on(
'app.message',
2014-02-22 01:13:31 -08:00
function(data){
ipc.log('got a message from world : ', data);
2014-02-22 01:13:31 -08:00
}
);
2015-08-22 23:16:20 -07:00
console.log(ipc.of.world.destroy);
2014-02-22 01:13:31 -08:00
}
2015-08-22 22:46:55 -07:00
);