fix: Handles max occupants reached from a visitor node.

When we receive the error from a visitor node, we need to restore the previous configuration, reconnect to the main prosody and be ready to try to rejoin again (from prejoin screen).
pull/13176/head jitsi-meet_8518
damencho 2 years ago committed by Дамян Минков
parent 2dac69b679
commit 352ffa589c
  1. 23
      conference.js
  2. 31
      react/features/base/conference/functions.ts
  3. 20
      react/features/base/conference/middleware.any.js
  4. 1
      react/features/base/config/reducer.ts

@ -58,6 +58,7 @@ import {
commonUserLeftHandling,
getConferenceOptions,
getVisitorOptions,
restoreConferenceOptions,
sendLocalParticipant
} from './react/features/base/conference/functions';
import { overwriteConfig } from './react/features/base/config/actions';
@ -402,10 +403,28 @@ class ConferenceConnector {
room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).then(() => connection.disconnect());
break;
case JitsiConferenceErrors.CONFERENCE_MAX_USERS:
case JitsiConferenceErrors.CONFERENCE_MAX_USERS: {
APP.UI.notifyMaxUsersLimitReached();
break;
// in case of max users(it can be from a visitor node), let's restore
// oldConfig if any as we will be back to the main prosody
const newConfig = restoreConferenceOptions(APP.store.getState());
if (newConfig) {
APP.store.dispatch(overwriteConfig(newConfig))
.then(this._conference.leaveRoom())
.then(() => {
_connectionPromise = connect(this._conference.roomName);
return _connectionPromise;
})
.then(con => {
APP.connection = connection = con;
});
}
break;
}
case JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS:
APP.store.dispatch(reloadWithStoredParams());
break;

@ -254,6 +254,33 @@ export function getConferenceOptions(stateful: IStateful) {
return options;
}
/**
* Returns the restored conference options if anything is available to be restored or undefined.
*
* @param {IStateful} stateful - The redux store state.
* @returns {Object?}
*/
export function restoreConferenceOptions(stateful: IStateful) {
const config = toState(stateful)['features/base/config'];
if (config.oldConfig) {
return {
hosts: {
domain: config.oldConfig.hosts.domain,
muc: config.oldConfig.hosts.muc
},
focusUserJid: config.oldConfig.focusUserJid,
disableFocus: false,
bosh: config.oldConfig.bosh,
websocket: config.oldConfig.websocket,
oldConfig: undefined
};
}
// nothing to return
return;
}
/**
* Override the global config (that is, window.config) with XMPP configuration required to join as a visitor.
*
@ -284,7 +311,8 @@ export function getVisitorOptions(stateful: IStateful, params: Array<string>) {
focusUserJid: focusJid,
bosh: config.oldConfig.bosh && appendURLParam(config.oldConfig.bosh, 'customusername', username),
websocket: config.oldConfig.websocket
&& appendURLParam(config.oldConfig.websocket, 'customusername', username)
&& appendURLParam(config.oldConfig.websocket, 'customusername', username),
oldConfig: undefined // clears it up
};
}
@ -296,6 +324,7 @@ export function getVisitorOptions(stateful: IStateful, params: Array<string>) {
domain: config.hosts.domain,
muc: config.hosts.muc
},
focusUserJid: config.focusUserJid,
bosh: config.bosh,
websocket: config.websocket
};

@ -52,7 +52,8 @@ import {
_removeLocalTracksFromConference,
forEachConference,
getCurrentConference,
getVisitorOptions
getVisitorOptions,
restoreConferenceOptions
} from './functions';
import logger from './logger';
@ -177,6 +178,23 @@ function _conferenceFailed({ dispatch, getState }, next, action) {
break;
}
case JitsiConferenceErrors.CONFERENCE_MAX_USERS: {
if (typeof APP === 'undefined') {
// in case of max users(it can be from a visitor node), let's restore
// oldConfig if any as we will be back to the main prosody
const newConfig = restoreConferenceOptions(getState);
if (newConfig) {
dispatch(overwriteConfig(newConfig))
.then(dispatch(conferenceWillLeave(conference)))
.then(conference.leave())
.then(dispatch(disconnect()))
.then(dispatch(connect()));
}
}
break;
}
case JitsiConferenceErrors.OFFER_ANSWER_FAILED:
sendAnalytics(createOfferAnswerFailedEvent());
break;

@ -86,6 +86,7 @@ export interface IConfigState extends IConfig {
error?: Error;
oldConfig?: {
bosh?: string;
focusUserJid?: string;
hosts: {
domain: string;
muc: string;

Loading…
Cancel
Save