Переглянути джерело

feat(iframe_api): Add invite functionality.

j8
hristoterezov 7 роки тому
джерело
коміт
69eefc82a5
3 змінених файлів з 54 додано та 6 видалено
  1. 15
    4
      doc/api.md
  2. 18
    1
      modules/API/API.js
  3. 21
    1
      modules/API/external/external_api.js

+ 15
- 4
doc/api.md Переглянути файл

@@ -28,6 +28,7 @@ Its constructor gets a number of options:
28 28
     * **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
29 29
     * **jwt**: (optional) [JWT](https://jwt.io/) token.
30 30
     * **onload**: (optional) handler for the iframe onload event.
31
+    * **invitees**: (optional) Array of objects containing information about new participants that will be invited in the call.
31 32
 
32 33
 Example:
33 34
 
@@ -296,32 +297,42 @@ var iframe = api.getIFrame();
296 297
 
297 298
 You can check whether the audio is muted with the following API function:
298 299
 ```javascript
299
-isAudioMuted().then(function(muted) {
300
+api.isAudioMuted().then(function(muted) {
300 301
     ...
301 302
 });
302 303
 ```
303 304
 
304 305
 You can check whether the video is muted with the following API function:
305 306
 ```javascript
306
-isVideoMuted().then(function(muted) {
307
+api.isVideoMuted().then(function(muted) {
307 308
     ...
308 309
 });
309 310
 ```
310 311
 
311 312
 You can check whether the audio is available with the following API function:
312 313
 ```javascript
313
-isAudioAvailable().then(function(available) {
314
+api.isAudioAvailable().then(function(available) {
314 315
     ...
315 316
 });
316 317
 ```
317 318
 
318 319
 You can check whether the video is available with the following API function:
319 320
 ```javascript
320
-isVideoAvailable().then(function(available) {
321
+api.isVideoAvailable().then(function(available) {
321 322
     ...
322 323
 });
323 324
 ```
324 325
 
326
+You can invite new participants to the call with the following API function:
327
+```javascript
328
+api.invite([{...}, {...}, {...}]).then(function() {
329
+    // success
330
+}).catch(function() {
331
+    // failure
332
+});
333
+```
334
+**NOTE: The format of the invitees in the array depends on the invite service used for the deployment.**
335
+
325 336
 You can remove the embedded Jitsi Meet Conference with the following API function:
326 337
 ```javascript
327 338
 api.dispose()

+ 18
- 1
modules/API/API.js Переглянути файл

@@ -6,6 +6,7 @@ import {
6 6
     createApiEvent,
7 7
     sendAnalytics
8 8
 } from '../../react/features/analytics';
9
+import { sendInvitesForItems } from '../../react/features/invite';
9 10
 import { getJitsiMeetTransport } from '../transport';
10 11
 
11 12
 import { API_ID } from './constants';
@@ -107,8 +108,24 @@ function initCommands() {
107 108
 
108 109
         return false;
109 110
     });
110
-    transport.on('request', ({ name }, callback) => {
111
+    transport.on('request', (request, callback) => {
112
+        const { name } = request;
113
+
111 114
         switch (name) {
115
+        case 'invite':
116
+            APP.store.dispatch(
117
+                sendInvitesForItems(request.invitees))
118
+                .then(failedInvites => {
119
+                    const failed = failedInvites.length === 0;
120
+
121
+                    callback({
122
+                        result: failed ? undefined : true,
123
+                        error: failed
124
+                            ? new Error('One or more invites failed!')
125
+                            : undefined
126
+                    });
127
+                });
128
+            break;
112 129
         case 'is-audio-muted':
113 130
             callback(APP.conference.isLocalAudioMuted());
114 131
             break;

+ 21
- 1
modules/API/external/external_api.js Переглянути файл

@@ -200,6 +200,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
200 200
      * authentication.
201 201
      * @param {string} [options.onload] - The onload function that will listen
202 202
      * for iframe onload event.
203
+     * @param {Array<Object>} [options.invitees] - Array of objects containing
204
+     * information about new participants that will be invited in the call.
203 205
      */
204 206
     constructor(domain, ...args) {
205 207
         super();
@@ -212,7 +214,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
212 214
             interfaceConfigOverwrite = {},
213 215
             noSSL = false,
214 216
             jwt = undefined,
215
-            onload = undefined
217
+            onload = undefined,
218
+            invitees
216 219
         } = parseArguments(args);
217 220
 
218 221
         this._parentNode = parentNode;
@@ -232,6 +235,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
232 235
                 }
233 236
             })
234 237
         });
238
+        this._invitees = invitees;
235 239
         this._isLargeVideoVisible = true;
236 240
         this._numberOfParticipants = 0;
237 241
         this._participants = {};
@@ -362,6 +366,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
362 366
 
363 367
             switch (name) {
364 368
             case 'video-conference-joined':
369
+                if (this._invitees) {
370
+                    this.invite(this._invitees);
371
+                }
365 372
                 this._myUserID = userID;
366 373
                 this._participants[userID] = {
367 374
                     avatarURL: data.avatarURL
@@ -575,6 +582,19 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
575 582
         });
576 583
     }
577 584
 
585
+    /**
586
+     * Invite people to the call.
587
+     *
588
+     * @param {Array<Object>} invitees - The invitees.
589
+     * @returns {Promise} - Resolves on success and rejects on failure.
590
+     */
591
+    invite(invitees) {
592
+        return this._transport.sendRequest({
593
+            name: 'invite',
594
+            invitees
595
+        });
596
+    }
597
+
578 598
     /**
579 599
      * Returns the audio mute status.
580 600
      *

Завантаження…
Відмінити
Зберегти