world-server.js 912 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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.serve(
  12. function(){
  13. ipc.server.on(
  14. 'app.message',
  15. function(data,socket){
  16. setTimeout(
  17. function(){
  18. ipc.server.emit(
  19. socket,
  20. 'app.message',
  21. {
  22. id : ipc.config.id,
  23. message : data.message+' world!'
  24. }
  25. );
  26. },
  27. 2000
  28. );
  29. }
  30. );
  31. }
  32. );
  33. ipc.server.start();