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