hello-client.js 1.1 KB

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