world-server.js 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.maxConnections=1;
  11. ipc.serveNet(
  12. function(){
  13. ipc.server.on(
  14. 'message',
  15. function(data,socket){
  16. ipc.log('got a message : ', data);
  17. ipc.server.emit(
  18. socket,
  19. 'message',
  20. data+' world!'
  21. );
  22. }
  23. );
  24. ipc.server.on(
  25. 'socket.disconnected',
  26. function(data,socket){
  27. console.log('DISCONNECTED\n\n',arguments);
  28. }
  29. );
  30. }
  31. );
  32. ipc.server.on(
  33. 'error',
  34. function(err){
  35. ipc.log('Got an ERROR!',err);
  36. }
  37. );
  38. ipc.server.start();