hello-client.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.networkHost='localhost';
  11. ipc.config.tls={
  12. private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
  13. public: __dirname+'/../../../local-node-ipc-certs/client.pub',
  14. rejectUnauthorized:true,
  15. trustedConnections: [
  16. __dirname+'/../../../local-node-ipc-certs/server.pub'
  17. ]
  18. };
  19. ipc.connectToNet(
  20. 'world',
  21. function(){
  22. ipc.of.world.on(
  23. 'connect',
  24. function(){
  25. ipc.log('## connected to world ##', ipc.config.delay);
  26. ipc.of.world.emit(
  27. 'message',
  28. 'hello'
  29. );
  30. }
  31. );
  32. ipc.of.world.on(
  33. 'disconnect',
  34. function(){
  35. ipc.log('disconnected from world');
  36. }
  37. );
  38. ipc.of.world.on(
  39. 'message',
  40. function(data){
  41. ipc.log('got a message from world : ', data);
  42. }
  43. );
  44. }
  45. );