hello-client.js 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.config.tls={
  11. rejectUnauthorized:false
  12. };
  13. ipc.connectToNet(
  14. 'world',
  15. function(){
  16. ipc.of.world.on(
  17. 'connect',
  18. function(){
  19. ipc.log('## connected to world ##', ipc.config.delay);
  20. ipc.of.world.emit(
  21. 'message',
  22. 'hello'
  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. 'message',
  34. function(data){
  35. ipc.log('got a message from world : ', data);
  36. }
  37. );
  38. }
  39. );