hello-client.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const ipc=require('../../../node-ipc');
  2. /***************************************\
  3. *
  4. * You should start both hello and world
  5. * then you will see them communicating.
  6. *
  7. * *************************************/
  8. ipc.config.id = 'hello';
  9. ipc.config.retry = 1000;
  10. ipc.connectTo(
  11. 'world',
  12. function(){
  13. ipc.of.world.on(
  14. 'connect',
  15. function(){
  16. ipc.log('## connected to world ##', ipc.config.delay);
  17. ipc.of.world.emit(
  18. 'app.message',
  19. {
  20. id : ipc.config.id,
  21. message : 'hello'
  22. }
  23. );
  24. }
  25. );
  26. ipc.of.world.on(
  27. 'disconnect',
  28. function(){
  29. ipc.log('disconnected from world');
  30. }
  31. );
  32. ipc.of.world.on(
  33. 'app.message',
  34. function(data){
  35. ipc.log('got a message from world : ', data);
  36. }
  37. );
  38. console.log(ipc.of.world.destroy);
  39. }
  40. );