Skip to content

Commit

Permalink
feat(visitors): Fire not live connection on jicofo response for visit…
Browse files Browse the repository at this point in the history
…ors.
  • Loading branch information
damencho committed Jun 28, 2024
1 parent 1993a03 commit ea523fc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion JitsiConnectionErrors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as exported from "./JitsiConnectionErrors";
describe( "/JitsiConnectionErrors members", () => {
const {
CONNECTION_DROPPED_ERROR,
NOT_LIVE_ERROR,
OTHER_ERROR,
PASSWORD_REQUIRED,
SERVER_ERROR,
Expand All @@ -21,6 +22,7 @@ describe( "/JitsiConnectionErrors members", () => {
expect( JitsiConnectionErrors ).toBeDefined();

expect( JitsiConnectionErrors.CONNECTION_DROPPED_ERROR ).toBe( 'connection.droppedError' );
expect( JitsiConnectionErrors.NOT_LIVE_ERROR ).toBe( 'connection.notLiveError' );
expect( JitsiConnectionErrors.OTHER_ERROR ).toBe( 'connection.otherError' );
expect( JitsiConnectionErrors.PASSWORD_REQUIRED ).toBe( 'connection.passwordRequired' );
expect( JitsiConnectionErrors.SERVER_ERROR ).toBe( 'connection.serverError' );
Expand All @@ -30,4 +32,4 @@ describe( "/JitsiConnectionErrors members", () => {
const keys = Object.keys( others );
expect( keys ).withContext( `Extra members: ${ keys.join( ", " ) }` ).toEqual( [] );
} );
} );
} );
6 changes: 6 additions & 0 deletions JitsiConnectionErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export enum JitsiConnectionErrors {
*/
CONNECTION_DROPPED_ERROR = 'connection.droppedError',

/**
* Not ready error. When the conference error is not ready according to jicofo.
*/
NOT_LIVE_ERROR = 'connection.notLiveError',

/**
* Not specified errors.
*/
Expand All @@ -35,6 +40,7 @@ export enum JitsiConnectionErrors {

// exported for backward compatibility
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;
export const PASSWORD_REQUIRED = JitsiConnectionErrors.PASSWORD_REQUIRED;
export const SERVER_ERROR = JitsiConnectionErrors.SERVER_ERROR;
18 changes: 17 additions & 1 deletion modules/xmpp/moderator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { getLogger } from '@jitsi/logger';
import $ from 'jquery';
import { $iq } from 'strophe.js';

import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
import { 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 @@ -276,6 +277,11 @@ export default class Moderator extends Listenable {
conferenceRequest.properties.sipGatewayEnabled = 'true';
}

// check for explicit false, all other cases is considered live
if ($(resultIq).find('>conference>property[name=\'live\'][value=\'false\']').length > 0) {
conferenceRequest.properties.live = 'false';
}

return conferenceRequest;
}

Expand Down Expand Up @@ -387,6 +393,16 @@ export default class Moderator extends Listenable {
this.sipGatewayEnabled = conferenceRequest.properties.sipGatewayEnabled;
logger.info(`Sip gateway enabled: ${this.sipGatewayEnabled}`);

if (conferenceRequest.properties.live === 'false' && this.options.preferVisitor) {
this.getNextTimeout(true);

logger.info('Conference is not live.');

this.xmpp.eventEmitter.emit(CONNECTION_FAILED, NOT_LIVE_ERROR);

return;
}

if (conferenceRequest.ready) {
// Reset the non-error timeout (because we've succeeded here).
this.getNextTimeout(true);
Expand Down
1 change: 1 addition & 0 deletions types/hand-crafted/JitsiConnectionErrors.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum JitsiConnectionErrors {
CONNECTION_DROPPED_ERROR = 'connection.droppedError',
NOT_LIVE_ERROR = 'connection.notLiveError',
OTHER_ERROR = 'connection.otherError',
PASSWORD_REQUIRED = 'connection.passwordRequired',
SERVER_ERROR = 'connection.serverError'
Expand Down

0 comments on commit ea523fc

Please sign in to comment.