hello-client.js 1.2 KB

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