hello-client.js 916 B

123456789101112131415161718192021222324252627282930313233343536373839
  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= 1500;
  10. ipc.connectToNet(
  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. 'message',
  19. 'hello'
  20. );
  21. }
  22. );
  23. ipc.of.world.on(
  24. 'disconnect',
  25. function(){
  26. ipc.log('disconnected from world');
  27. }
  28. );
  29. ipc.of.world.on(
  30. 'message',
  31. function(data){
  32. ipc.log('got a message from world : ', data);
  33. }
  34. );
  35. }
  36. );