goodbye-client.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 = 'goodbye';
  9. ipc.config.retry= 1500;
  10. ipc.config.maxRetries= 10;
  11. ipc.config.tls={
  12. rejectUnauthorized:false
  13. };
  14. ipc.connectToNet(
  15. 'world',
  16. function(){
  17. ipc.of.world.on(
  18. 'connect',
  19. function(){
  20. ipc.log('## connected to world ##', ipc.config.delay);
  21. ipc.of.world.emit(
  22. 'app.message',
  23. {
  24. id : ipc.config.id,
  25. message : 'goodbye'
  26. }
  27. );
  28. }
  29. );
  30. ipc.of.world.on(
  31. 'disconnect',
  32. function(){
  33. ipc.log('disconnected from world');
  34. }
  35. );
  36. ipc.of.world.on(
  37. 'kill.connection',
  38. function(data){
  39. ipc.log('world requested kill.connection');
  40. ipc.disconnect('world');
  41. }
  42. );
  43. }
  44. );