world.server.js 864 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.rawBuffer=true;
  11. ipc.config.encoding='ascii';
  12. ipc.serve(
  13. function(){
  14. ipc.server.on(
  15. 'connect',
  16. function(socket){
  17. ipc.server.emit(
  18. socket,
  19. 'hello'
  20. );
  21. }
  22. );
  23. ipc.server.on(
  24. 'data',
  25. function(data,socket){
  26. ipc.log('got a message', data,data.toString());
  27. ipc.server.emit(
  28. socket,
  29. 'goodbye'
  30. );
  31. }
  32. );
  33. }
  34. );
  35. ipc.server.start();