feat(iframe_api): Add invite functionality.
This commit is contained in:
parent
d1af11c67e
commit
69eefc82a5
19
doc/api.md
19
doc/api.md
|
@ -28,6 +28,7 @@ Its constructor gets a number of options:
|
||||||
* **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
|
* **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
|
||||||
* **jwt**: (optional) [JWT](https://jwt.io/) token.
|
* **jwt**: (optional) [JWT](https://jwt.io/) token.
|
||||||
* **onload**: (optional) handler for the iframe onload event.
|
* **onload**: (optional) handler for the iframe onload event.
|
||||||
|
* **invitees**: (optional) Array of objects containing information about new participants that will be invited in the call.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -296,32 +297,42 @@ var iframe = api.getIFrame();
|
||||||
|
|
||||||
You can check whether the audio is muted with the following API function:
|
You can check whether the audio is muted with the following API function:
|
||||||
```javascript
|
```javascript
|
||||||
isAudioMuted().then(function(muted) {
|
api.isAudioMuted().then(function(muted) {
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
You can check whether the video is muted with the following API function:
|
You can check whether the video is muted with the following API function:
|
||||||
```javascript
|
```javascript
|
||||||
isVideoMuted().then(function(muted) {
|
api.isVideoMuted().then(function(muted) {
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
You can check whether the audio is available with the following API function:
|
You can check whether the audio is available with the following API function:
|
||||||
```javascript
|
```javascript
|
||||||
isAudioAvailable().then(function(available) {
|
api.isAudioAvailable().then(function(available) {
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
You can check whether the video is available with the following API function:
|
You can check whether the video is available with the following API function:
|
||||||
```javascript
|
```javascript
|
||||||
isVideoAvailable().then(function(available) {
|
api.isVideoAvailable().then(function(available) {
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can invite new participants to the call with the following API function:
|
||||||
|
```javascript
|
||||||
|
api.invite([{...}, {...}, {...}]).then(function() {
|
||||||
|
// success
|
||||||
|
}).catch(function() {
|
||||||
|
// failure
|
||||||
|
});
|
||||||
|
```
|
||||||
|
**NOTE: The format of the invitees in the array depends on the invite service used for the deployment.**
|
||||||
|
|
||||||
You can remove the embedded Jitsi Meet Conference with the following API function:
|
You can remove the embedded Jitsi Meet Conference with the following API function:
|
||||||
```javascript
|
```javascript
|
||||||
api.dispose()
|
api.dispose()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
createApiEvent,
|
createApiEvent,
|
||||||
sendAnalytics
|
sendAnalytics
|
||||||
} from '../../react/features/analytics';
|
} from '../../react/features/analytics';
|
||||||
|
import { sendInvitesForItems } from '../../react/features/invite';
|
||||||
import { getJitsiMeetTransport } from '../transport';
|
import { getJitsiMeetTransport } from '../transport';
|
||||||
|
|
||||||
import { API_ID } from './constants';
|
import { API_ID } from './constants';
|
||||||
|
@ -107,8 +108,24 @@ function initCommands() {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
transport.on('request', ({ name }, callback) => {
|
transport.on('request', (request, callback) => {
|
||||||
|
const { name } = request;
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
case 'invite':
|
||||||
|
APP.store.dispatch(
|
||||||
|
sendInvitesForItems(request.invitees))
|
||||||
|
.then(failedInvites => {
|
||||||
|
const failed = failedInvites.length === 0;
|
||||||
|
|
||||||
|
callback({
|
||||||
|
result: failed ? undefined : true,
|
||||||
|
error: failed
|
||||||
|
? new Error('One or more invites failed!')
|
||||||
|
: undefined
|
||||||
|
});
|
||||||
|
});
|
||||||
|
break;
|
||||||
case 'is-audio-muted':
|
case 'is-audio-muted':
|
||||||
callback(APP.conference.isLocalAudioMuted());
|
callback(APP.conference.isLocalAudioMuted());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -200,6 +200,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
* authentication.
|
* authentication.
|
||||||
* @param {string} [options.onload] - The onload function that will listen
|
* @param {string} [options.onload] - The onload function that will listen
|
||||||
* for iframe onload event.
|
* for iframe onload event.
|
||||||
|
* @param {Array<Object>} [options.invitees] - Array of objects containing
|
||||||
|
* information about new participants that will be invited in the call.
|
||||||
*/
|
*/
|
||||||
constructor(domain, ...args) {
|
constructor(domain, ...args) {
|
||||||
super();
|
super();
|
||||||
|
@ -212,7 +214,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
interfaceConfigOverwrite = {},
|
interfaceConfigOverwrite = {},
|
||||||
noSSL = false,
|
noSSL = false,
|
||||||
jwt = undefined,
|
jwt = undefined,
|
||||||
onload = undefined
|
onload = undefined,
|
||||||
|
invitees
|
||||||
} = parseArguments(args);
|
} = parseArguments(args);
|
||||||
|
|
||||||
this._parentNode = parentNode;
|
this._parentNode = parentNode;
|
||||||
|
@ -232,6 +235,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
this._invitees = invitees;
|
||||||
this._isLargeVideoVisible = true;
|
this._isLargeVideoVisible = true;
|
||||||
this._numberOfParticipants = 0;
|
this._numberOfParticipants = 0;
|
||||||
this._participants = {};
|
this._participants = {};
|
||||||
|
@ -362,6 +366,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'video-conference-joined':
|
case 'video-conference-joined':
|
||||||
|
if (this._invitees) {
|
||||||
|
this.invite(this._invitees);
|
||||||
|
}
|
||||||
this._myUserID = userID;
|
this._myUserID = userID;
|
||||||
this._participants[userID] = {
|
this._participants[userID] = {
|
||||||
avatarURL: data.avatarURL
|
avatarURL: data.avatarURL
|
||||||
|
@ -575,6 +582,19 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invite people to the call.
|
||||||
|
*
|
||||||
|
* @param {Array<Object>} invitees - The invitees.
|
||||||
|
* @returns {Promise} - Resolves on success and rejects on failure.
|
||||||
|
*/
|
||||||
|
invite(invitees) {
|
||||||
|
return this._transport.sendRequest({
|
||||||
|
name: 'invite',
|
||||||
|
invitees
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the audio mute status.
|
* Returns the audio mute status.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue