world-server.js 1.1 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 = 'world';
  9. ipc.config.retry= 1500;
  10. ipc.config.sync= true;
  11. ipc.config.tls={
  12. public: __dirname+'/../../../local-node-ipc-certs/server.pub',
  13. private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
  14. };
  15. ipc.serveNet(
  16. function(){
  17. ipc.server.on(
  18. 'message',
  19. function(data,socket){
  20. ipc.log('got a message : ', data);
  21. setTimeout(
  22. function(){
  23. ipc.server.emit(
  24. socket,
  25. 'message',
  26. data+' world!'
  27. );
  28. },
  29. 3000
  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();