world-server.js 1.1 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 = 'world';
  9. ipc.config.retry= 1500;
  10. ipc.config.tls={
  11. public: __dirname+'/../../../local-node-ipc-certs/server.pub',
  12. private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
  13. dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
  14. requestCert: true,
  15. rejectUnauthorized:false,
  16. trustedConnections: [
  17. __dirname+'/../../../local-node-ipc-certs/client.pub'
  18. ]
  19. };
  20. ipc.serveNet(
  21. function(){
  22. ipc.server.on(
  23. 'message',
  24. function(data,socket){
  25. ipc.log('got a message : ', data);
  26. ipc.server.emit(
  27. socket,
  28. 'message',
  29. data+' world!'
  30. );
  31. }
  32. );
  33. ipc.server.on(
  34. 'socket.disconnected',
  35. function(data,socket){
  36. console.log(arguments);
  37. }
  38. );
  39. }
  40. );
  41. ipc.server.start();