diff --git a/doc/api.md b/doc/api.md index 1fa24f056..9fa82e448 100644 --- a/doc/api.md +++ b/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. * **jwt**: (optional) [JWT](https://jwt.io/) token. * **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: @@ -296,32 +297,42 @@ var iframe = api.getIFrame(); You can check whether the audio is muted with the following API function: ```javascript -isAudioMuted().then(function(muted) { +api.isAudioMuted().then(function(muted) { ... }); ``` You can check whether the video is muted with the following API function: ```javascript -isVideoMuted().then(function(muted) { +api.isVideoMuted().then(function(muted) { ... }); ``` You can check whether the audio is available with the following API function: ```javascript -isAudioAvailable().then(function(available) { +api.isAudioAvailable().then(function(available) { ... }); ``` You can check whether the video is available with the following API function: ```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: ```javascript api.dispose() diff --git a/modules/API/API.js b/modules/API/API.js index 2b8f32e9b..d25b4596e 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -6,6 +6,7 @@ import { createApiEvent, sendAnalytics } from '../../react/features/analytics'; +import { sendInvitesForItems } from '../../react/features/invite'; import { getJitsiMeetTransport } from '../transport'; import { API_ID } from './constants'; @@ -107,8 +108,24 @@ function initCommands() { return false; }); - transport.on('request', ({ name }, callback) => { + transport.on('request', (request, callback) => { + const { name } = request; + 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': callback(APP.conference.isLocalAudioMuted()); break; diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 7e837def1..fa5271cb4 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -200,6 +200,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * authentication. * @param {string} [options.onload] - The onload function that will listen * for iframe onload event. + * @param {Array} [options.invitees] - Array of objects containing + * information about new participants that will be invited in the call. */ constructor(domain, ...args) { super(); @@ -212,7 +214,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { interfaceConfigOverwrite = {}, noSSL = false, jwt = undefined, - onload = undefined + onload = undefined, + invitees } = parseArguments(args); this._parentNode = parentNode; @@ -232,6 +235,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter { } }) }); + this._invitees = invitees; this._isLargeVideoVisible = true; this._numberOfParticipants = 0; this._participants = {}; @@ -362,6 +366,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter { switch (name) { case 'video-conference-joined': + if (this._invitees) { + this.invite(this._invitees); + } this._myUserID = userID; this._participants[userID] = { avatarURL: data.avatarURL @@ -575,6 +582,19 @@ export default class JitsiMeetExternalAPI extends EventEmitter { }); } + /** + * Invite people to the call. + * + * @param {Array} 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. *