Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix: Handles max occupants reached from a visitor node.

damencho352ffa589c44
diff --git a/conference.js b/conference.js
index 7c33507852..7bb9dbd0e9 100644
--- a/conference.js
+++ b/conference.js
@@ -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;
diff --git a/react/features/base/conference/functions.ts b/react/features/base/conference/functions.ts
index c6a5f904d6..89b12b63c8 100644
--- a/react/features/base/conference/functions.ts
+++ b/react/features/base/conference/functions.ts
@@ -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
};
diff --git a/react/features/base/conference/middleware.any.js b/react/features/base/conference/middleware.any.js
index 43c45fabdc..f3886b0bbd 100644
--- a/react/features/base/conference/middleware.any.js
+++ b/react/features/base/conference/middleware.any.js
@@ -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;
diff --git a/react/features/base/config/reducer.ts b/react/features/base/config/reducer.ts
index a26de5c6be..1f9d34de7d 100644
--- a/react/features/base/config/reducer.ts
+++ b/react/features/base/config/reducer.ts
@@ -86,6 +86,7 @@ export interface IConfigState extends IConfig {
error?: Error;
oldConfig?: {
bosh?: string;
+ focusUserJid?: string;
hosts: {
domain: string;
muc: string;