hello-client.js 800 B

123456789101112131415161718192021222324252627282930313233343536
  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.connectTo(
  13. 'world',
  14. function(){
  15. ipc.of.world.on(
  16. 'connect',
  17. function(){
  18. ipc.log('## connected to world ##', ipc.config.delay);
  19. ipc.of.world.emit(
  20. 'hello'
  21. );
  22. }
  23. );
  24. ipc.of.world.on(
  25. 'data',
  26. function(data){
  27. ipc.log('got a message from world : ', data,data.toString());
  28. }
  29. );
  30. }
  31. );