Bladeren bron

feat(external-api): add knocking event and approve/reject command (#10210)

master
Mihaela Dumitru 4 jaren geleden
bovenliggende
commit
f435fc4ade
No account linked to committer's email address
3 gewijzigde bestanden met toevoegingen van 27 en 1 verwijderingen
  1. 17
    1
      modules/API/API.js
  2. 2
    0
      modules/API/external/external_api.js
  3. 8
    0
      react/features/lobby/middleware.js

+ 17
- 1
modules/API/API.js Bestand weergeven

@@ -61,7 +61,7 @@ import {
61 61
     captureLargeVideoScreenshot,
62 62
     resizeLargeVideo
63 63
 } from '../../react/features/large-video/actions.web';
64
-import { toggleLobbyMode } from '../../react/features/lobby/actions';
64
+import { toggleLobbyMode, setKnockingParticipantApproval } from '../../react/features/lobby/actions';
65 65
 import { isForceMuted } from '../../react/features/participants-pane/functions';
66 66
 import { RECORDING_TYPES } from '../../react/features/recording/constants';
67 67
 import { getActiveSession } from '../../react/features/recording/functions';
@@ -113,6 +113,9 @@ let videoAvailable = true;
113 113
  */
114 114
 function initCommands() {
115 115
     commands = {
116
+        'answer-knocking-participant': (id, approved) => {
117
+            APP.store.dispatch(setKnockingParticipantApproval(id, approved));
118
+        },
116 119
         'approve-video': participantId => {
117 120
             if (!isLocalParticipantModerator(APP.store.getState())) {
118 121
                 return;
@@ -1458,6 +1461,19 @@ class API {
1458 1461
         });
1459 1462
     }
1460 1463
 
1464
+    /**
1465
+     * Notify external application (if API is enabled) that a participant is knocking in the lobby.
1466
+     *
1467
+     * @param {Object} participant - Participant data such as id and name.
1468
+     * @returns {void}
1469
+     */
1470
+    notifyKnockingParticipant(participant: Object) {
1471
+        this._sendEvent({
1472
+            name: 'knocking-participant',
1473
+            participant
1474
+        });
1475
+    }
1476
+
1461 1477
     /**
1462 1478
      * Notify external application (if API is enabled) that an error occured.
1463 1479
      *

+ 2
- 0
modules/API/external/external_api.js Bestand weergeven

@@ -27,6 +27,7 @@ const ALWAYS_ON_TOP_FILENAMES = [
27 27
  * commands expected by jitsi-meet
28 28
  */
29 29
 const commands = {
30
+    answerKnockingParticipant: 'answer-knocking-participant',
30 31
     approveVideo: 'approve-video',
31 32
     askToUnmute: 'ask-to-unmute',
32 33
     avatarUrl: 'avatar-url',
@@ -94,6 +95,7 @@ const events = {
94 95
     'feedback-prompt-displayed': 'feedbackPromptDisplayed',
95 96
     'filmstrip-display-changed': 'filmstripDisplayChanged',
96 97
     'incoming-message': 'incomingMessage',
98
+    'knocking-participant': 'knockingParticipant',
97 99
     'log': 'log',
98 100
     'mic-error': 'micError',
99 101
     'moderation-participant-approved': 'moderationParticipantApproved',

+ 8
- 0
react/features/lobby/middleware.js Bestand weergeven

@@ -25,6 +25,8 @@ import {
25 25
 import { KNOCKING_PARTICIPANT_SOUND_ID } from './constants';
26 26
 import { KNOCKING_PARTICIPANT_FILE } from './sounds';
27 27
 
28
+declare var APP: Object;
29
+
28 30
 MiddlewareRegistry.register(store => next => action => {
29 31
     switch (action.type) {
30 32
     case APP_WILL_MOUNT:
@@ -69,6 +71,12 @@ StateListenerRegistry.register(
69 71
                         name
70 72
                     }));
71 73
                     dispatch(playSound(KNOCKING_PARTICIPANT_SOUND_ID));
74
+                    if (typeof APP !== 'undefined') {
75
+                        APP.API.notifyKnockingParticipant({
76
+                            id,
77
+                            name
78
+                        });
79
+                    }
72 80
                 });
73 81
             });
74 82
 

Laden…
Annuleren
Opslaan