hello-client.js 1.1 KB

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