hello-client.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.sync= true;
  11. ipc.config.tls={
  12. rejectUnauthorized:false
  13. };
  14. ipc.connectToNet(
  15. 'world',
  16. function(){
  17. ipc.of.world.on(
  18. 'connect',
  19. function(){
  20. ipc.log('## connected to world ##', ipc.config.delay);
  21. //queue up a bunch of requests to be sent synchronously
  22. for(var i=0; i<10; i++){
  23. ipc.of.world.emit(
  24. 'message',
  25. 'hello'+i
  26. );
  27. }
  28. }
  29. );
  30. ipc.of.world.on(
  31. 'disconnect',
  32. function(){
  33. ipc.log('disconnected from world');
  34. }
  35. );
  36. ipc.of.world.on(
  37. 'message',
  38. function(data){
  39. ipc.log('got a message from world : ', data);
  40. }
  41. );
  42. }
  43. );