hello-client.js 886 B

1234567891011121314151617181920212223242526272829303132333435
  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 = 'hello';
  9. ipc.config.retry= 1500;
  10. ipc.config.rawBuffer=true;
  11. ipc.config.encoding='ascii';
  12. ipc.serveNet(
  13. 8001, //we set the port here because the world server is already using the default of 8000. So we can not bind to 8000 while world is using it.
  14. 'udp4',
  15. function(){
  16. ipc.server.on(
  17. 'data',
  18. function(data){
  19. ipc.log('got a message from world ', data, data.toString());
  20. }
  21. );
  22. ipc.server.emit(
  23. {
  24. address : 'localhost',
  25. port : ipc.config.networkPort
  26. },
  27. 'hello'
  28. );
  29. }
  30. );
  31. ipc.server.start();