feat(conference) send leave reasons on switching room and when errors occur

This commit is contained in:
Duduman Bogdan Vlad 2022-08-26 12:53:32 +03:00 committed by GitHub
parent 85d2123fac
commit fc60ab8383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View File

@ -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();
}

View File

@ -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'
};

View File

@ -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);

View File

@ -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);