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(external-api): add knocking event and approve/reject command (#10210)

Mihaela Dumitruf435fc4adebb
diff --git a/modules/API/API.js b/modules/API/API.js
index 21f291471b..9975ad729f 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -61,7 +61,7 @@ import {
captureLargeVideoScreenshot,
resizeLargeVideo
} from '../../react/features/large-video/actions.web';
-import { toggleLobbyMode } from '../../react/features/lobby/actions';
+import { toggleLobbyMode, setKnockingParticipantApproval } from '../../react/features/lobby/actions';
import { isForceMuted } from '../../react/features/participants-pane/functions';
import { RECORDING_TYPES } from '../../react/features/recording/constants';
import { getActiveSession } from '../../react/features/recording/functions';
@@ -113,6 +113,9 @@ let videoAvailable = true;
*/
function initCommands() {
commands = {
+ 'answer-knocking-participant': (id, approved) => {
+ APP.store.dispatch(setKnockingParticipantApproval(id, approved));
+ },
'approve-video': participantId => {
if (!isLocalParticipantModerator(APP.store.getState())) {
return;
@@ -1458,6 +1461,19 @@ class API {
});
}
+ /**
+ * Notify external application (if API is enabled) that a participant is knocking in the lobby.
+ *
+ * @param {Object} participant - Participant data such as id and name.
+ * @returns {void}
+ */
+ notifyKnockingParticipant(participant: Object) {
+ this._sendEvent({
+ name: 'knocking-participant',
+ participant
+ });
+ }
+
/**
* Notify external application (if API is enabled) that an error occured.
*
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index fc19cacb06..112555a8a8 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -27,6 +27,7 @@ const ALWAYS_ON_TOP_FILENAMES = [
* commands expected by jitsi-meet
*/
const commands = {
+ answerKnockingParticipant: 'answer-knocking-participant',
approveVideo: 'approve-video',
askToUnmute: 'ask-to-unmute',
avatarUrl: 'avatar-url',
@@ -94,6 +95,7 @@ const events = {
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
'filmstrip-display-changed': 'filmstripDisplayChanged',
'incoming-message': 'incomingMessage',
+ 'knocking-participant': 'knockingParticipant',
'log': 'log',
'mic-error': 'micError',
'moderation-participant-approved': 'moderationParticipantApproved',
diff --git a/react/features/lobby/middleware.js b/react/features/lobby/middleware.js
index 3671a9f6dc..9cd506be44 100644
--- a/react/features/lobby/middleware.js
+++ b/react/features/lobby/middleware.js
@@ -25,6 +25,8 @@ import {
import { KNOCKING_PARTICIPANT_SOUND_ID } from './constants';
import { KNOCKING_PARTICIPANT_FILE } from './sounds';
+declare var APP: Object;
+
MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case APP_WILL_MOUNT:
@@ -69,6 +71,12 @@ StateListenerRegistry.register(
name
}));
dispatch(playSound(KNOCKING_PARTICIPANT_SOUND_ID));
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyKnockingParticipant({
+ id,
+ name
+ });
+ }
});
});