Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

IceFailedNotification.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* global __filename */
  2. import { getLogger } from 'jitsi-meet-logger';
  3. const logger = getLogger(__filename);
  4. /**
  5. * A delayed ICE failed notification which is triggered only if the ICE
  6. * connection does not recover soon after or before the XMPP connection is
  7. * restored (if it was ever broken). If ICE fails while the XMPP connection is
  8. * not broken then the notifications will be sent after 2 seconds delay. This
  9. * extra delay is not intentional just a side effect of the code.
  10. * NOTE that this delayed task can only be used if PING is supported by the XMPP
  11. * server.
  12. */
  13. export default class IceFailedNotification {
  14. /**
  15. * Creates new {@code DelayedIceFailed} task.
  16. * @param {JitsiConference} conference
  17. */
  18. constructor(conference) {
  19. this._conference = conference;
  20. }
  21. /**
  22. * Starts the task.
  23. * @param {JingleSessionPC} session - the JVB Jingle session.
  24. */
  25. start(session) {
  26. // The 65 seconds are greater than the default Prosody's BOSH
  27. // timeout of 60. This gives some time for the XMPP connection
  28. // to recover.
  29. this._conference.xmpp.ping(65000).then(
  30. () => {
  31. if (this._canceled) {
  32. return;
  33. }
  34. if (this._conference.isJvbConnectionInterrupted) {
  35. this._iceFailedTimeout = window.setTimeout(() => {
  36. logger.info(
  37. 'Sending ICE failed'
  38. + ' - the connection has not recovered');
  39. this._iceFailedTimeout = undefined;
  40. session.sendIceFailedNotification();
  41. }, 2000);
  42. } else {
  43. logger.info(
  44. 'ICE connection restored - not sending ICE failed');
  45. }
  46. },
  47. error => {
  48. logger.error(
  49. 'PING error/timeout - not sending ICE failed', error);
  50. });
  51. }
  52. /**
  53. * Cancels the task.
  54. */
  55. cancel() {
  56. this._canceled = true;
  57. if (this._iceFailedTimeout) {
  58. window.clearTimeout(this._iceFailedTimeout);
  59. }
  60. }
  61. }