world-server.js 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. };
  14. ipc.serveNet(
  15. function(){
  16. ipc.server.on(
  17. 'message',
  18. function(data,socket){
  19. ipc.log('got a message : ', data);
  20. ipc.server.emit(
  21. socket,
  22. 'message',
  23. data+' world!'
  24. );
  25. }
  26. );
  27. ipc.server.on(
  28. 'socket.disconnected',
  29. function(data,socket){
  30. console.log(arguments);
  31. }
  32. );
  33. }
  34. );
  35. ipc.server.start();