Skip to content

Commit

Permalink
feat(moderator): Fires new error on connection failed for conference …
Browse files Browse the repository at this point in the history
…request failures. (#2591)

* feat(moderator): Fires new error on connection failed for conference request failures.

* squash: Fix tests.
  • Loading branch information
damencho authored Oct 26, 2024
1 parent ce3d05e commit 5d53ecd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions JitsiConnectionErrors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as exported from "./JitsiConnectionErrors";

describe( "/JitsiConnectionErrors members", () => {
const {
CONFERENCE_REQUEST_FAILED,
CONNECTION_DROPPED_ERROR,
NOT_LIVE_ERROR,
OTHER_ERROR,
Expand All @@ -14,13 +15,16 @@ describe( "/JitsiConnectionErrors members", () => {
} = exported;

it( "known members", () => {
expect( CONFERENCE_REQUEST_FAILED ).toBe( 'connection.conferenceRequestFailed' );
expect( CONNECTION_DROPPED_ERROR ).toBe( 'connection.droppedError' );
expect( NOT_LIVE_ERROR ).toBe( 'connection.notLiveError' );
expect( OTHER_ERROR ).toBe( 'connection.otherError' );
expect( PASSWORD_REQUIRED ).toBe( 'connection.passwordRequired' );
expect( SERVER_ERROR ).toBe( 'connection.serverError' );

expect( JitsiConnectionErrors ).toBeDefined();

expect( JitsiConnectionErrors.CONFERENCE_REQUEST_FAILED ).toBe( 'connection.conferenceRequestFailed' );
expect( JitsiConnectionErrors.CONNECTION_DROPPED_ERROR ).toBe( 'connection.droppedError' );
expect( JitsiConnectionErrors.NOT_LIVE_ERROR ).toBe( 'connection.notLiveError' );
expect( JitsiConnectionErrors.OTHER_ERROR ).toBe( 'connection.otherError' );
Expand Down
6 changes: 6 additions & 0 deletions JitsiConnectionErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/

export enum JitsiConnectionErrors {
/**
* When the conference-request to jicofo fails.
*/
CONFERENCE_REQUEST_FAILED = "connection.conferenceRequestFailed",

/**
* Indicates that the connection was dropped with an error which was most likely
* caused by some networking issues. The dropped term in this context means that
Expand Down Expand Up @@ -39,6 +44,7 @@ export enum JitsiConnectionErrors {
};

// exported for backward compatibility
export const CONFERENCE_REQUEST_FAILED = JitsiConnectionErrors.CONFERENCE_REQUEST_FAILED;
export const CONNECTION_DROPPED_ERROR = JitsiConnectionErrors.CONNECTION_DROPPED_ERROR;
export const NOT_LIVE_ERROR = JitsiConnectionErrors.NOT_LIVE_ERROR;
export const OTHER_ERROR = JitsiConnectionErrors.OTHER_ERROR;
Expand Down
9 changes: 4 additions & 5 deletions modules/xmpp/moderator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getLogger } from '@jitsi/logger';
import $ from 'jquery';
import { $iq } from 'strophe.js';

import { NOT_LIVE_ERROR } from '../../JitsiConnectionErrors';
import { CONFERENCE_REQUEST_FAILED, NOT_LIVE_ERROR } from '../../JitsiConnectionErrors';
import { CONNECTION_FAILED, CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
import Settings from '../settings/Settings';
import Listenable from '../util/Listenable';
Expand Down Expand Up @@ -339,7 +339,7 @@ export default class Moderator extends Listenable {
})
.catch(error => {
logger.warn(`Error: ${error}`);
this._handleError(roomJid, undefined, undefined, resolve, reject);
this._handleError(roomJid, undefined, undefined, resolve, () => reject(error));
});

// _handleError has either scheduled a retry or fired an event indicating failure.
Expand All @@ -352,7 +352,7 @@ export default class Moderator extends Listenable {
})
.catch(error => {
logger.warn(`Error: ${error}`);
this._handleError(roomJid, undefined, undefined, resolve, reject);
this._handleError(roomJid, undefined, undefined, resolve, () => reject(error));
});
}
}).then(() => {
Expand Down Expand Up @@ -487,8 +487,7 @@ export default class Moderator extends Listenable {
logger.error('Failed to get a successful response, giving up.');

// This is a "fatal" error and the user of the lib should handle it accordingly.
// TODO: change the event name to something accurate.
this.eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED);
this.xmpp.eventEmitter.emit(CONNECTION_FAILED, CONFERENCE_REQUEST_FAILED);

errorCallback();
}
Expand Down

0 comments on commit 5d53ecd

Please sign in to comment.