Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(conference) send leave reasons on switching room and when errors occur
Duduman Bogdan Vladfc60ab838302
diff --git a/conference.js b/conference.jsindex 626bcdd7ec..f9681bd681 100644--- a/conference.js+++ b/conference.js@@ -52,7 +52,8 @@ import {onStartMutedPolicyChanged,p2pStatusChanged,sendLocalParticipant,- nonParticipantMessageReceived+ nonParticipantMessageReceived,+ CONFERENCE_LEAVE_REASONS} from './react/features/base/conference';import {getReplaceParticipant,@@ -381,7 +382,7 @@ class ConferenceConnector {// FIXME the conference should be stopped by the library and not by// the app. Both the errors above are unrecoverable from the library// perspective.- room.leave().then(() => connection.disconnect());+ room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).then(() => connection.disconnect());break;case JitsiConferenceErrors.CONFERENCE_MAX_USERS:@@ -464,7 +465,7 @@ function _connectionFailedHandler(error) {_connectionFailedHandler);if (room) {APP.store.dispatch(conferenceWillLeave(room));- room.leave();+ room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR);}}}@@ -3059,13 +3060,14 @@ export default {* Leaves the room.** @param {boolean} doDisconnect - Whether leaving the room should also terminate the connection.+ * @param {string} reason - reason for leaving the room.* @returns {Promise}*/- async leaveRoom(doDisconnect = true) {+ async leaveRoom(doDisconnect = true, reason = '') {APP.store.dispatch(conferenceWillLeave(room));if (room && room.isJoined()) {- return room.leave().finally(() => {+ return room.leave(reason).finally(() => {if (doDisconnect) {return disconnect();}diff --git a/react/features/base/conference/constants.js b/react/features/base/conference/constants.jsindex 62f85aa25f..ced7c15393 100644--- a/react/features/base/conference/constants.js+++ b/react/features/base/conference/constants.js@@ -31,3 +31,11 @@ export const JITSI_CONFERENCE_URL_KEY = Symbol('url');export const TRIGGER_READY_TO_CLOSE_REASONS = ['The meeting has been terminated'];++/**+ * Conference leave reasons.+ */+export const CONFERENCE_LEAVE_REASONS = {+ SWITCH_ROOM: 'switch_room',+ UNRECOVERABLE_ERROR: 'unrecoverable_error'+};diff --git a/react/features/base/conference/middleware.any.js b/react/features/base/conference/middleware.any.jsindex 035cd682d8..a5e57c47f3 100644--- a/react/features/base/conference/middleware.any.js+++ b/react/features/base/conference/middleware.any.js@@ -46,7 +46,7 @@ import {setLocalSubject,setSubject} from './actions';-import { TRIGGER_READY_TO_CLOSE_REASONS } from './constants';+import { CONFERENCE_LEAVE_REASONS, TRIGGER_READY_TO_CLOSE_REASONS } from './constants';import {_addLocalTracksToConference,_removeLocalTracksFromConference,@@ -177,7 +177,7 @@ function _conferenceFailed({ dispatch, getState }, next, action) {if (typeof APP === 'undefined') {!error.recoverable&& conference- && conference.leave().catch(reason => {+ && conference.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR).catch(reason => {// Even though we don't care too much about the failure, it may be// good to know that it happen, so log it (on the info level).logger.info('JitsiConference.leave() rejected with:', reason);diff --git a/react/features/breakout-rooms/actions.js b/react/features/breakout-rooms/actions.jsindex 7a47aac30a..f2761f4b9f 100644--- a/react/features/breakout-rooms/actions.js+++ b/react/features/breakout-rooms/actions.js@@ -6,6 +6,7 @@ import type { Dispatch } from 'redux';import { createBreakoutRoomsEvent, sendAnalytics } from '../analytics';import {+ CONFERENCE_LEAVE_REASONS,conferenceLeft,conferenceWillLeave,createConference,@@ -225,7 +226,7 @@ export function moveToRoom(roomId?: string) {dispatch(conferenceWillLeave(conference));try {- await conference.leave();+ await conference.leave(CONFERENCE_LEAVE_REASONS.SWITCH_ROOM);} catch (error) {logger.warn('JitsiConference.leave() rejected with:', error);@@ -246,7 +247,7 @@ export function moveToRoom(roomId?: string) {try {// all places we fire notifyConferenceLeft we pass the room name from APP.conference- await APP.conference.leaveRoom(false /* doDisconnect */).then(+ await APP.conference.leaveRoom(false /* doDisconnect */, CONFERENCE_LEAVE_REASONS.SWITCH_ROOM).then(() => APP.API.notifyConferenceLeft(APP.conference.roomName));} catch (error) {logger.warn('APP.conference.leaveRoom() rejected with:', error);