Browse Source

feat(iframe_api): Add invite functionality.

j8
hristoterezov 7 years ago
parent
commit
69eefc82a5
3 changed files with 54 additions and 6 deletions
  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 View File

28
     * **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
28
     * **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
29
     * **jwt**: (optional) [JWT](https://jwt.io/) token.
29
     * **jwt**: (optional) [JWT](https://jwt.io/) token.
30
     * **onload**: (optional) handler for the iframe onload event.
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
 Example:
33
 Example:
33
 
34
 
296
 
297
 
297
 You can check whether the audio is muted with the following API function:
298
 You can check whether the audio is muted with the following API function:
298
 ```javascript
299
 ```javascript
299
-isAudioMuted().then(function(muted) {
300
+api.isAudioMuted().then(function(muted) {
300
     ...
301
     ...
301
 });
302
 });
302
 ```
303
 ```
303
 
304
 
304
 You can check whether the video is muted with the following API function:
305
 You can check whether the video is muted with the following API function:
305
 ```javascript
306
 ```javascript
306
-isVideoMuted().then(function(muted) {
307
+api.isVideoMuted().then(function(muted) {
307
     ...
308
     ...
308
 });
309
 });
309
 ```
310
 ```
310
 
311
 
311
 You can check whether the audio is available with the following API function:
312
 You can check whether the audio is available with the following API function:
312
 ```javascript
313
 ```javascript
313
-isAudioAvailable().then(function(available) {
314
+api.isAudioAvailable().then(function(available) {
314
     ...
315
     ...
315
 });
316
 });
316
 ```
317
 ```
317
 
318
 
318
 You can check whether the video is available with the following API function:
319
 You can check whether the video is available with the following API function:
319
 ```javascript
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
 You can remove the embedded Jitsi Meet Conference with the following API function:
336
 You can remove the embedded Jitsi Meet Conference with the following API function:
326
 ```javascript
337
 ```javascript
327
 api.dispose()
338
 api.dispose()

+ 18
- 1
modules/API/API.js View File

6
     createApiEvent,
6
     createApiEvent,
7
     sendAnalytics
7
     sendAnalytics
8
 } from '../../react/features/analytics';
8
 } from '../../react/features/analytics';
9
+import { sendInvitesForItems } from '../../react/features/invite';
9
 import { getJitsiMeetTransport } from '../transport';
10
 import { getJitsiMeetTransport } from '../transport';
10
 
11
 
11
 import { API_ID } from './constants';
12
 import { API_ID } from './constants';
107
 
108
 
108
         return false;
109
         return false;
109
     });
110
     });
110
-    transport.on('request', ({ name }, callback) => {
111
+    transport.on('request', (request, callback) => {
112
+        const { name } = request;
113
+
111
         switch (name) {
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
         case 'is-audio-muted':
129
         case 'is-audio-muted':
113
             callback(APP.conference.isLocalAudioMuted());
130
             callback(APP.conference.isLocalAudioMuted());
114
             break;
131
             break;

+ 21
- 1
modules/API/external/external_api.js View File

200
      * authentication.
200
      * authentication.
201
      * @param {string} [options.onload] - The onload function that will listen
201
      * @param {string} [options.onload] - The onload function that will listen
202
      * for iframe onload event.
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
     constructor(domain, ...args) {
206
     constructor(domain, ...args) {
205
         super();
207
         super();
212
             interfaceConfigOverwrite = {},
214
             interfaceConfigOverwrite = {},
213
             noSSL = false,
215
             noSSL = false,
214
             jwt = undefined,
216
             jwt = undefined,
215
-            onload = undefined
217
+            onload = undefined,
218
+            invitees
216
         } = parseArguments(args);
219
         } = parseArguments(args);
217
 
220
 
218
         this._parentNode = parentNode;
221
         this._parentNode = parentNode;
232
                 }
235
                 }
233
             })
236
             })
234
         });
237
         });
238
+        this._invitees = invitees;
235
         this._isLargeVideoVisible = true;
239
         this._isLargeVideoVisible = true;
236
         this._numberOfParticipants = 0;
240
         this._numberOfParticipants = 0;
237
         this._participants = {};
241
         this._participants = {};
362
 
366
 
363
             switch (name) {
367
             switch (name) {
364
             case 'video-conference-joined':
368
             case 'video-conference-joined':
369
+                if (this._invitees) {
370
+                    this.invite(this._invitees);
371
+                }
365
                 this._myUserID = userID;
372
                 this._myUserID = userID;
366
                 this._participants[userID] = {
373
                 this._participants[userID] = {
367
                     avatarURL: data.avatarURL
374
                     avatarURL: data.avatarURL
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
      * Returns the audio mute status.
599
      * Returns the audio mute status.
580
      *
600
      *

Loading…
Cancel
Save