Skip to content

Commit

Permalink
feat(conference) send leave reasons on switching room and when errors…
Browse files Browse the repository at this point in the history
… occur
  • Loading branch information
dudumanbogdan authored Aug 26, 2022
1 parent 85d2123 commit fc60ab8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
12 changes: 7 additions & 5 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import {
onStartMutedPolicyChanged,
p2pStatusChanged,
sendLocalParticipant,
nonParticipantMessageReceived
nonParticipantMessageReceived,
CONFERENCE_LEAVE_REASONS
} from './react/features/base/conference';
import {
getReplaceParticipant,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -464,7 +465,7 @@ function _connectionFailedHandler(error) {
_connectionFailedHandler);
if (room) {
APP.store.dispatch(conferenceWillLeave(room));
room.leave();
room.leave(CONFERENCE_LEAVE_REASONS.UNRECOVERABLE_ERROR);
}
}
}
Expand Down Expand Up @@ -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();
}
Expand Down
8 changes: 8 additions & 0 deletions react/features/base/conference/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
4 changes: 2 additions & 2 deletions react/features/base/conference/middleware.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions react/features/breakout-rooms/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Dispatch } from 'redux';

import { createBreakoutRoomsEvent, sendAnalytics } from '../analytics';
import {
CONFERENCE_LEAVE_REASONS,
conferenceLeft,
conferenceWillLeave,
createConference,
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit fc60ab8

Please sign in to comment.