Skip to content

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

feat(conference): Adds option to silently reconnect.

damencho19cff49ab15a
diff --git a/react/features/base/conference/functions.ts b/react/features/base/conference/functions.ts
index 5db9f934c0..fef9fe745f 100644
--- a/react/features/base/conference/functions.ts
+++ b/react/features/base/conference/functions.ts
@@ -7,6 +7,8 @@ import { showNotification } from '../../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
import { determineTranscriptionLanguage } from '../../transcribing/functions';
import { IStateful } from '../app/types';
+import { connect } from '../connection/actions';
+import { disconnect } from '../connection/actions.any';
import { JitsiTrackErrors } from '../lib-jitsi-meet';
import { setAudioMuted, setVideoMuted } from '../media/actions';
import { VIDEO_MUTISM_AUTHORITY } from '../media/constants';
@@ -22,7 +24,7 @@ import {
safeDecodeURIComponent
} from '../util/uri';
-import { setObfuscatedRoom } from './actions';
+import { conferenceWillInit, setObfuscatedRoom } from './actions';
import {
AVATAR_URL_COMMAND,
EMAIL_COMMAND,
@@ -618,3 +620,34 @@ export function updateTrackMuteState(stateful: IStateful, dispatch: IStore['disp
}, NOTIFICATION_TIMEOUT_TYPE.SHORT));
}
}
+
+/**
+ * Processes the "destroyed" event of a conference and if the destroyed conference is the current one,
+ * it silently reconnects to the same room.
+ *
+ * @param {Object|Function} stateful - Either the whole Redux state object or the Redux store's {@code getState} method.
+ * @param {Function} dispatch - Redux dispatch function.
+ * @param {Array} params - The parameters for the destroy event.
+ *
+ * @returns {boolean} - True if the destroyed conference was the current one, and we are reconnecting, false otherwise.
+ */
+export function processDestroyConferenceEvent(stateful: IStateful, dispatch: IStore['dispatch'], params: Array<any>) {
+ const [ jid ] = params;
+ const conference = getCurrentConference(stateful);
+
+ // if the jid of the room is the same as the current conference, we are being
+ // notified that the current conference has been destroyed, and we need to reconnect
+ if (conference?.room?.roomjid === jid) {
+ dispatch(disconnect(true, false))
+ .then(() => {
+ dispatch(conferenceWillInit());
+ logger.info('Dispatching silent re-connect.');
+
+ return dispatch(connect());
+ });
+
+ return true;
+ }
+
+ return false;
+}
diff --git a/react/features/base/conference/middleware.native.ts b/react/features/base/conference/middleware.native.ts
index ffde497098..b8db7dc1c0 100644
--- a/react/features/base/conference/middleware.native.ts
+++ b/react/features/base/conference/middleware.native.ts
@@ -6,8 +6,8 @@ import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import { CONFERENCE_FAILED } from './actionTypes';
import { conferenceLeft } from './actions.native';
import { TRIGGER_READY_TO_CLOSE_REASONS } from './constants';
-
import './middleware.any';
+import { processDestroyConferenceEvent } from './functions';
MiddlewareRegistry.register(store => next => action => {
const { dispatch } = store;
@@ -23,6 +23,10 @@ MiddlewareRegistry.register(store => next => action => {
break;
}
+ if (processDestroyConferenceEvent(state, dispatch, error.params)) {
+ break;
+ }
+
if (!notifyOnConferenceDestruction) {
dispatch(conferenceLeft(action.conference));
dispatch(appNavigate(undefined));
diff --git a/react/features/base/conference/middleware.web.ts b/react/features/base/conference/middleware.web.ts
index 9af879152a..143c9fd79b 100644
--- a/react/features/base/conference/middleware.web.ts
+++ b/react/features/base/conference/middleware.web.ts
@@ -24,8 +24,8 @@ import {
KICKED_OUT
} from './actionTypes';
import { TRIGGER_READY_TO_CLOSE_REASONS } from './constants';
+import { processDestroyConferenceEvent } from './functions';
import logger from './logger';
-
import './middleware.any';
let screenLock: WakeLockSentinel | undefined;
@@ -127,6 +127,11 @@ MiddlewareRegistry.register(store => next => action => {
const state = getState();
const { notifyOnConferenceDestruction = true } = state['features/base/config'];
const [ reason ] = action.error.params;
+
+ if (processDestroyConferenceEvent(state, dispatch, action.error.params)) {
+ break;
+ }
+
const titlekey = Object.keys(TRIGGER_READY_TO_CLOSE_REASONS)[
Object.values(TRIGGER_READY_TO_CLOSE_REASONS).indexOf(reason)
];
diff --git a/react/features/base/connection/actions.any.ts b/react/features/base/connection/actions.any.ts
index 547993762f..e431be0684 100644
--- a/react/features/base/connection/actions.any.ts
+++ b/react/features/base/connection/actions.any.ts
@@ -385,10 +385,10 @@ function _propertiesUpdate(properties: object) {
* Closes connection.
*
* @param {boolean} isRedirect - Indicates if the action has been dispatched as part of visitor promotion.
- *
+ * @param {boolean} shouldLeave - Indicates whether to call JitsiConference.leave().
* @returns {Function}
*/
-export function disconnect(isRedirect?: boolean) {
+export function disconnect(isRedirect?: boolean, shouldLeave = true) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']): Promise<void> => {
const state = getState();
@@ -407,20 +407,26 @@ export function disconnect(isRedirect?: boolean) {
// intention to leave the conference.
dispatch(conferenceWillLeave(conference_, isRedirect));
- promise
- = conference_.leave()
- .catch((error: Error) => {
- logger.warn(
- 'JitsiConference.leave() rejected with:',
- error);
-
- // The library lib-jitsi-meet failed to make the
- // JitsiConference leave. Which may be because
- // JitsiConference thinks it has already left.
- // Regardless of the failure reason, continue in
- // jitsi-meet as if the leave has succeeded.
- dispatch(conferenceLeft(conference_));
- });
+ if (!shouldLeave) {
+ // we are skipping JitsiConference.leave(), but will still dispatch the normal leave flow events
+ dispatch(conferenceLeft(conference_));
+ promise = Promise.resolve();
+ } else {
+ promise
+ = conference_.leave()
+ .catch((error: Error) => {
+ logger.warn(
+ 'JitsiConference.leave() rejected with:',
+ error);
+
+ // The library lib-jitsi-meet failed to make the
+ // JitsiConference leave. Which may be because
+ // JitsiConference thinks it has already left.
+ // Regardless of the failure reason, continue in
+ // jitsi-meet as if the leave has succeeded.
+ dispatch(conferenceLeft(conference_));
+ });
+ }
} else {
promise = Promise.resolve();
}
diff --git a/resources/prosody-plugins/mod_muc_end_meeting.lua b/resources/prosody-plugins/mod_muc_end_meeting.lua
index cb1d3ef496..28e1630856 100644
--- a/resources/prosody-plugins/mod_muc_end_meeting.lua
+++ b/resources/prosody-plugins/mod_muc_end_meeting.lua
@@ -6,6 +6,7 @@ module:set_global();
local util = module:require "util";
local async_handler_wrapper = util.async_handler_wrapper;
+local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
local room_jid_match_rewrite = util.room_jid_match_rewrite;
local get_room_from_jid = util.get_room_from_jid;
local starts_with = util.starts_with;
@@ -17,6 +18,8 @@ local parse = neturl.parseQuery;
local token_util;
local muc_domain_base = module:get_option_string("muc_mapper_domain_base");
+local muc_domain_prefix = module:get_option_string('muc_mapper_domain_prefix', 'conference');
+local muc_domain = muc_domain_prefix..'.'..muc_domain_base;
local asapKeyServer = module:get_option_string("prosody_password_public_key_repo_url", "");
@@ -47,6 +50,7 @@ function handle_terminate_meeting (event)
end
local params = parse(event.request.url.query);
local conference = params["conference"];
+ local silent_reconnect = params['silent-reconnect'];
local room_jid;
if conference then
@@ -78,8 +82,13 @@ function handle_terminate_meeting (event)
module:log("warn", "Room not found")
return { status_code = 404 };
else
- module:log("info", "Destroy room jid %s", room.jid)
- room:destroy(nil, "The meeting has been terminated")
+ if silent_reconnect == 'true' then
+ module:log('info', 'Setting silent_reconnect on room %s', room.jid);
+ room:destroy(internal_room_jid_match_rewrite(room.jid), 'The meeting has been terminated silently')
+ else
+ module:log("info", "Destroy room jid %s", room.jid)
+ room:destroy(nil, "The meeting has been terminated")
+ end
end
event_count_success()
return { status_code = 200 };