123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /* global __filename */
- import { getLogger } from 'jitsi-meet-logger';
-
- const logger = getLogger(__filename);
-
- /**
- * A delayed ICE failed notification which is triggered only if the ICE
- * connection does not recover soon after or before the XMPP connection is
- * restored (if it was ever broken). If ICE fails while the XMPP connection is
- * not broken then the notifications will be sent after 2 seconds delay. This
- * extra delay is not intentional just a side effect of the code.
- * NOTE that this delayed task can only be used if PING is supported by the XMPP
- * server.
- */
- export default class IceFailedNotification {
- /**
- * Creates new {@code DelayedIceFailed} task.
- * @param {JitsiConference} conference
- */
- constructor(conference) {
- this._conference = conference;
- }
-
- /**
- * Starts the task.
- * @param {JingleSessionPC} session - the JVB Jingle session.
- */
- start(session) {
- // The 65 seconds are greater than the default Prosody's BOSH
- // timeout of 60. This gives some time for the XMPP connection
- // to recover.
- this._conference.xmpp.ping(65000).then(
- () => {
- if (this._canceled) {
- return;
- }
-
- if (this._conference.isJvbConnectionInterrupted) {
- this._iceFailedTimeout = window.setTimeout(() => {
- logger.info(
- 'Sending ICE failed'
- + ' - the connection has not recovered');
- this._iceFailedTimeout = undefined;
- session.sendIceFailedNotification();
- }, 2000);
- } else {
- logger.info(
- 'ICE connection restored - not sending ICE failed');
- }
- },
- error => {
- logger.error(
- 'PING error/timeout - not sending ICE failed', error);
- });
- }
-
- /**
- * Cancels the task.
- */
- cancel() {
- this._canceled = true;
- if (this._iceFailedTimeout) {
- window.clearTimeout(this._iceFailedTimeout);
- }
- }
- }
|