2017-10-03 19:24:00 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-04-17 15:52:31 +00:00
|
|
|
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
2017-12-11 18:48:32 +00:00
|
|
|
import {
|
2018-01-03 21:24:07 +00:00
|
|
|
createApiEvent,
|
|
|
|
sendAnalytics
|
2017-12-11 18:48:32 +00:00
|
|
|
} from '../../react/features/analytics';
|
2018-05-03 01:20:31 +00:00
|
|
|
import { parseJWTFromURLParams } from '../../react/features/base/jwt';
|
|
|
|
import { invite } from '../../react/features/invite';
|
2017-04-28 20:24:20 +00:00
|
|
|
import { getJitsiMeetTransport } from '../transport';
|
2016-11-11 15:00:54 +00:00
|
|
|
|
2017-04-17 15:52:31 +00:00
|
|
|
import { API_ID } from './constants';
|
2016-06-13 21:11:44 +00:00
|
|
|
|
2017-10-09 21:40:38 +00:00
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|
|
|
|
2017-04-17 15:52:31 +00:00
|
|
|
declare var APP: Object;
|
2017-04-06 22:09:55 +00:00
|
|
|
|
2015-01-09 13:39:32 +00:00
|
|
|
/**
|
|
|
|
* List of the available commands.
|
|
|
|
*/
|
2016-06-13 21:11:44 +00:00
|
|
|
let commands = {};
|
|
|
|
|
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* The state of screen sharing(started/stopped) before the screen sharing is
|
|
|
|
* enabled and initialized.
|
|
|
|
* NOTE: This flag help us to cache the state and use it if toggle-share-screen
|
|
|
|
* was received before the initialization.
|
2016-06-13 21:11:44 +00:00
|
|
|
*/
|
2017-04-11 19:30:00 +00:00
|
|
|
let initialScreenSharingState = false;
|
2016-06-13 21:11:44 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-28 20:24:20 +00:00
|
|
|
* The transport instance used for communication with external apps.
|
|
|
|
*
|
|
|
|
* @type {Transport}
|
2016-06-13 21:11:44 +00:00
|
|
|
*/
|
2017-04-28 20:24:20 +00:00
|
|
|
const transport = getJitsiMeetTransport();
|
2017-04-06 22:09:55 +00:00
|
|
|
|
2017-08-04 08:15:11 +00:00
|
|
|
/**
|
|
|
|
* The current audio availability.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
let audioAvailable = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current video availability.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
let videoAvailable = true;
|
|
|
|
|
2017-04-11 18:02:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes supported commands.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2015-07-02 21:33:06 +00:00
|
|
|
function initCommands() {
|
2015-07-28 18:22:11 +00:00
|
|
|
commands = {
|
2018-01-03 21:24:07 +00:00
|
|
|
'display-name': displayName => {
|
|
|
|
sendAnalytics(createApiEvent('display.name.changed'));
|
|
|
|
APP.conference.changeLocalDisplayName(displayName);
|
|
|
|
},
|
2018-01-19 22:19:55 +00:00
|
|
|
'submit-feedback': feedback => {
|
|
|
|
sendAnalytics(createApiEvent('submit.feedback'));
|
|
|
|
APP.conference.submitFeedback(feedback.score, feedback.message);
|
|
|
|
},
|
2017-07-25 10:05:08 +00:00
|
|
|
'toggle-audio': () => {
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createApiEvent('toggle-audio'));
|
2017-10-09 21:40:38 +00:00
|
|
|
logger.log('Audio toggle: API command received');
|
2017-07-25 10:05:08 +00:00
|
|
|
APP.conference.toggleAudioMuted(false /* no UI */);
|
|
|
|
},
|
2017-07-20 12:29:15 +00:00
|
|
|
'toggle-video': () => {
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createApiEvent('toggle-video'));
|
2017-10-09 21:40:38 +00:00
|
|
|
logger.log('Video toggle: API command received');
|
2017-07-20 12:29:15 +00:00
|
|
|
APP.conference.toggleVideoMuted(false /* no UI */);
|
|
|
|
},
|
2018-01-03 21:24:07 +00:00
|
|
|
'toggle-film-strip': () => {
|
|
|
|
sendAnalytics(createApiEvent('film.strip.toggled'));
|
|
|
|
APP.UI.toggleFilmstrip();
|
|
|
|
},
|
|
|
|
'toggle-chat': () => {
|
|
|
|
sendAnalytics(createApiEvent('chat.toggled'));
|
|
|
|
APP.UI.toggleChat();
|
|
|
|
},
|
|
|
|
'toggle-share-screen': () => {
|
|
|
|
sendAnalytics(createApiEvent('screen.sharing.toggled'));
|
|
|
|
toggleScreenSharing();
|
|
|
|
},
|
|
|
|
'video-hangup': () => {
|
|
|
|
sendAnalytics(createApiEvent('video.hangup'));
|
|
|
|
APP.conference.hangup(true);
|
|
|
|
},
|
|
|
|
'email': email => {
|
|
|
|
sendAnalytics(createApiEvent('email.changed'));
|
|
|
|
APP.conference.changeLocalEmail(email);
|
|
|
|
},
|
|
|
|
'avatar-url': avatarUrl => {
|
|
|
|
sendAnalytics(createApiEvent('avatar.url.changed'));
|
|
|
|
APP.conference.changeLocalAvatarUrl(avatarUrl);
|
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
};
|
2017-04-27 20:21:01 +00:00
|
|
|
transport.on('event', ({ data, name }) => {
|
2017-04-17 15:52:31 +00:00
|
|
|
if (name && commands[name]) {
|
|
|
|
commands[name](...data);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2018-04-30 12:08:11 +00:00
|
|
|
transport.on('request', (request, callback) => {
|
|
|
|
const { name } = request;
|
|
|
|
|
2017-08-04 08:15:11 +00:00
|
|
|
switch (name) {
|
2018-10-02 13:03:23 +00:00
|
|
|
case 'invite': {
|
2018-08-03 17:06:06 +00:00
|
|
|
const { invitees } = request;
|
|
|
|
|
|
|
|
if (!Array.isArray(invitees) || invitees.length === 0) {
|
|
|
|
callback({
|
|
|
|
error: new Error('Unexpected format of invitees')
|
|
|
|
});
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-06-26 22:56:22 +00:00
|
|
|
// The store should be already available because API.init is called
|
|
|
|
// on appWillMount action.
|
2018-04-30 12:08:11 +00:00
|
|
|
APP.store.dispatch(
|
2018-08-03 17:06:06 +00:00
|
|
|
invite(invitees, true))
|
2018-05-03 01:20:31 +00:00
|
|
|
.then(failedInvitees => {
|
|
|
|
let error;
|
|
|
|
let result;
|
|
|
|
|
|
|
|
if (failedInvitees.length) {
|
|
|
|
error = new Error('One or more invites failed!');
|
|
|
|
} else {
|
|
|
|
result = true;
|
|
|
|
}
|
2018-04-30 12:08:11 +00:00
|
|
|
|
|
|
|
callback({
|
2018-05-03 01:20:31 +00:00
|
|
|
error,
|
|
|
|
result
|
2018-04-30 12:08:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
break;
|
2018-10-02 13:03:23 +00:00
|
|
|
}
|
2017-08-04 08:15:11 +00:00
|
|
|
case 'is-audio-muted':
|
2017-08-28 21:56:27 +00:00
|
|
|
callback(APP.conference.isLocalAudioMuted());
|
2017-08-04 08:15:11 +00:00
|
|
|
break;
|
|
|
|
case 'is-video-muted':
|
2017-08-28 21:56:27 +00:00
|
|
|
callback(APP.conference.isLocalVideoMuted());
|
2017-08-04 08:15:11 +00:00
|
|
|
break;
|
|
|
|
case 'is-audio-available':
|
|
|
|
callback(audioAvailable);
|
|
|
|
break;
|
|
|
|
case 'is-video-available':
|
|
|
|
callback(videoAvailable);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
2015-07-02 21:33:06 +00:00
|
|
|
}
|
2015-01-09 13:39:32 +00:00
|
|
|
|
2017-04-11 19:30:00 +00:00
|
|
|
/**
|
|
|
|
* Listens for desktop/screen sharing enabled events and toggles the screen
|
|
|
|
* sharing if needed.
|
|
|
|
*
|
|
|
|
* @param {boolean} enabled - Current screen sharing enabled status.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onDesktopSharingEnabledChanged(enabled = false) {
|
|
|
|
if (enabled && initialScreenSharingState) {
|
|
|
|
toggleScreenSharing();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:05:54 +00:00
|
|
|
/**
|
|
|
|
* Check whether the API should be enabled or not.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
2016-01-14 15:05:54 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2017-04-11 18:02:59 +00:00
|
|
|
function shouldBeEnabled() {
|
2017-05-26 22:11:33 +00:00
|
|
|
return (
|
|
|
|
typeof API_ID === 'number'
|
|
|
|
|
|
|
|
// XXX Enable the API when a JSON Web Token (JWT) is specified in
|
|
|
|
// the location/URL because then it is very likely that the Jitsi
|
|
|
|
// Meet (Web) app is being used by an external/wrapping (Web) app
|
|
|
|
// and, consequently, the latter will need to communicate with the
|
|
|
|
// former. (The described logic is merely a heuristic though.)
|
|
|
|
|| parseJWTFromURLParams());
|
2015-01-23 15:36:17 +00:00
|
|
|
}
|
|
|
|
|
2016-01-14 15:05:54 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Executes on toggle-share-screen command.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-01-14 15:05:54 +00:00
|
|
|
*/
|
2017-04-11 19:30:00 +00:00
|
|
|
function toggleScreenSharing() {
|
|
|
|
if (APP.conference.isDesktopSharingEnabled) {
|
2017-08-21 08:57:58 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-empty-function
|
|
|
|
APP.conference.toggleScreenSharing().catch(() => {});
|
2017-04-11 19:30:00 +00:00
|
|
|
} else {
|
|
|
|
initialScreenSharingState = !initialScreenSharingState;
|
2016-01-14 15:05:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:02:59 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Implements API class that communicates with external API class and provides
|
|
|
|
* interface to access Jitsi Meet features by external applications that embed
|
|
|
|
* Jitsi Meet.
|
2017-04-11 18:02:59 +00:00
|
|
|
*/
|
2016-12-20 22:15:13 +00:00
|
|
|
class API {
|
2017-10-02 23:08:07 +00:00
|
|
|
_enabled: boolean;
|
|
|
|
|
2015-01-09 13:39:32 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Initializes the API. Setups message event listeners that will receive
|
|
|
|
* information from external applications that embed Jitsi Meet. It also
|
|
|
|
* sends a message to the external application that API is initialized.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @param {Object} options - Optional parameters.
|
|
|
|
* @returns {void}
|
2015-01-09 13:39:32 +00:00
|
|
|
*/
|
2017-05-26 22:11:33 +00:00
|
|
|
init() {
|
|
|
|
if (!shouldBeEnabled()) {
|
2016-01-14 15:05:54 +00:00
|
|
|
return;
|
2017-04-11 18:02:59 +00:00
|
|
|
}
|
2016-06-13 21:11:44 +00:00
|
|
|
|
2017-04-17 15:52:31 +00:00
|
|
|
/**
|
|
|
|
* Current status (enabled/disabled) of API.
|
2017-04-27 20:21:01 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
2017-04-17 15:52:31 +00:00
|
|
|
*/
|
2017-04-27 20:21:01 +00:00
|
|
|
this._enabled = true;
|
2017-04-17 15:52:31 +00:00
|
|
|
|
|
|
|
APP.conference.addListener(
|
|
|
|
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
|
|
|
onDesktopSharingEnabledChanged);
|
|
|
|
|
|
|
|
initCommands();
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
|
|
|
|
2017-12-05 03:27:17 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that the large video
|
|
|
|
* visibility changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} isHidden - True if the large video is hidden and false
|
|
|
|
* otherwise.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyLargeVideoVisibilityChanged(isHidden: boolean) {
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'large-video-visibility-changed',
|
|
|
|
isVisible: !isHidden
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-12-20 22:15:13 +00:00
|
|
|
/**
|
2017-05-01 20:59:18 +00:00
|
|
|
* Sends event to the external application.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
2017-05-01 20:59:18 +00:00
|
|
|
* @param {Object} event - The event to be sent.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2016-12-20 22:15:13 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
_sendEvent(event: Object = {}) {
|
2017-04-27 20:21:01 +00:00
|
|
|
if (this._enabled) {
|
2017-05-01 20:59:18 +00:00
|
|
|
transport.sendEvent(event);
|
2017-04-11 18:02:59 +00:00
|
|
|
}
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-01-14 15:05:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that message was sent.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
2017-04-17 15:52:31 +00:00
|
|
|
* @param {string} message - Message body.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2016-01-14 15:05:54 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifySendingChatMessage(message: string) {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'outgoing-message',
|
|
|
|
message
|
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-06-13 21:11:44 +00:00
|
|
|
|
2015-01-09 13:39:32 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that message was
|
|
|
|
* received.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @param {Object} options - Object with the message properties.
|
|
|
|
* @returns {void}
|
2015-01-09 13:39:32 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
notifyReceivedChatMessage(
|
|
|
|
{ body, id, nick, ts }: {
|
|
|
|
body: *, id: string, nick: string, ts: *
|
|
|
|
} = {}) {
|
2016-01-14 15:05:54 +00:00
|
|
|
if (APP.conference.isLocalId(id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'incoming-message',
|
2017-04-17 15:52:31 +00:00
|
|
|
from: id,
|
|
|
|
message: body,
|
2017-04-27 20:21:01 +00:00
|
|
|
nick,
|
2017-04-17 15:52:31 +00:00
|
|
|
stamp: ts
|
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2015-01-09 13:39:32 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that user joined the
|
|
|
|
* conference.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - User id.
|
2017-12-05 03:27:17 +00:00
|
|
|
* @param {Object} props - The display name of the user.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2015-01-09 13:39:32 +00:00
|
|
|
*/
|
2017-12-05 03:27:17 +00:00
|
|
|
notifyUserJoined(id: string, props: Object) {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'participant-joined',
|
2017-12-05 03:27:17 +00:00
|
|
|
id,
|
|
|
|
...props
|
2017-05-01 20:59:18 +00:00
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-01-14 15:05:54 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that user left the
|
|
|
|
* conference.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - User id.
|
|
|
|
* @returns {void}
|
2016-01-14 15:05:54 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyUserLeft(id: string) {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'participant-left',
|
|
|
|
id
|
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-01-14 15:05:54 +00:00
|
|
|
|
2017-12-05 03:27:17 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that user changed their
|
|
|
|
* avatar.
|
|
|
|
*
|
|
|
|
* @param {string} id - User id.
|
|
|
|
* @param {string} avatarURL - The new avatar URL of the participant.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyAvatarChanged(id: string, avatarURL: string) {
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'avatar-changed',
|
|
|
|
avatarURL,
|
|
|
|
id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:05:54 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that user changed their
|
|
|
|
* nickname.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - User id.
|
2017-04-17 15:52:31 +00:00
|
|
|
* @param {string} displayname - User nickname.
|
2017-12-05 03:27:17 +00:00
|
|
|
* @param {string} formattedDisplayName - The display name shown in Jitsi
|
|
|
|
* meet's UI for the user.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2016-01-14 15:05:54 +00:00
|
|
|
*/
|
2017-12-05 03:27:17 +00:00
|
|
|
notifyDisplayNameChanged(
|
|
|
|
id: string,
|
|
|
|
{ displayName, formattedDisplayName }: Object) {
|
2017-05-02 22:39:36 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'display-name-change',
|
2017-12-05 03:27:17 +00:00
|
|
|
displayname: displayName,
|
|
|
|
formattedDisplayName,
|
2017-04-27 20:21:01 +00:00
|
|
|
id
|
2017-04-17 15:52:31 +00:00
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-06-17 20:35:40 +00:00
|
|
|
|
2018-06-18 09:19:07 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that user changed their
|
|
|
|
* email.
|
|
|
|
*
|
|
|
|
* @param {string} id - User id.
|
|
|
|
* @param {string} email - The new email of the participant.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyEmailChanged(
|
|
|
|
id: string,
|
|
|
|
{ email }: Object) {
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'email-change',
|
|
|
|
email,
|
|
|
|
id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-17 20:35:40 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that the conference has
|
|
|
|
* been joined.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
2017-04-17 15:52:31 +00:00
|
|
|
* @param {string} roomName - The room name.
|
2017-12-05 03:27:17 +00:00
|
|
|
* @param {string} id - The id of the local user.
|
|
|
|
* @param {Object} props - The display name and avatar URL of the local
|
|
|
|
* user.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2016-06-17 20:35:40 +00:00
|
|
|
*/
|
2017-12-05 03:27:17 +00:00
|
|
|
notifyConferenceJoined(roomName: string, id: string, props: Object) {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'video-conference-joined',
|
2017-12-05 03:27:17 +00:00
|
|
|
roomName,
|
|
|
|
id,
|
|
|
|
...props
|
2017-05-01 20:59:18 +00:00
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-06-17 20:35:40 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that user changed their
|
|
|
|
* nickname.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
2017-04-17 15:52:31 +00:00
|
|
|
* @param {string} roomName - User id.
|
2017-04-11 18:02:59 +00:00
|
|
|
* @returns {void}
|
2016-06-17 20:35:40 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyConferenceLeft(roomName: string) {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'video-conference-left',
|
|
|
|
roomName
|
|
|
|
});
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2015-01-09 13:39:32 +00:00
|
|
|
|
2016-10-05 21:33:09 +00:00
|
|
|
/**
|
2017-04-11 19:30:00 +00:00
|
|
|
* Notify external application (if API is enabled) that we are ready to be
|
|
|
|
* closed.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-10-05 21:33:09 +00:00
|
|
|
*/
|
2017-04-11 18:02:59 +00:00
|
|
|
notifyReadyToClose() {
|
2017-05-01 20:59:18 +00:00
|
|
|
this._sendEvent({ name: 'video-ready-to-close' });
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-10-05 21:33:09 +00:00
|
|
|
|
2017-08-04 08:15:11 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) for audio muted status
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} muted - The new muted status.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyAudioMutedStatusChanged(muted: boolean) {
|
2017-08-04 08:15:11 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'audio-mute-status-changed',
|
|
|
|
muted
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) for video muted status
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} muted - The new muted status.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyVideoMutedStatusChanged(muted: boolean) {
|
2017-08-04 08:15:11 +00:00
|
|
|
this._sendEvent({
|
|
|
|
name: 'video-mute-status-changed',
|
|
|
|
muted
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) for audio availability
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} available - True if available and false otherwise.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyAudioAvailabilityChanged(available: boolean) {
|
2017-08-04 08:15:11 +00:00
|
|
|
audioAvailable = available;
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'audio-availability-changed',
|
|
|
|
available
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) for video available
|
|
|
|
* status changed.
|
|
|
|
*
|
|
|
|
* @param {boolean} available - True if available and false otherwise.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
notifyVideoAvailabilityChanged(available: boolean) {
|
2017-08-04 08:15:11 +00:00
|
|
|
videoAvailable = available;
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'video-availability-changed',
|
|
|
|
available
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-05 03:27:17 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that the on stage
|
|
|
|
* participant has changed.
|
|
|
|
*
|
|
|
|
* @param {string} id - User id of the new on stage participant.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyOnStageParticipantChanged(id: string) {
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'on-stage-participant-changed',
|
|
|
|
id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-19 22:19:55 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that conference feedback
|
|
|
|
* has been submitted. Intended to be used in conjunction with the
|
|
|
|
* submit-feedback command to get notified if feedback was submitted.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyFeedbackSubmitted() {
|
|
|
|
this._sendEvent({ name: 'feedback-submitted' });
|
|
|
|
}
|
2017-08-04 08:15:11 +00:00
|
|
|
|
2018-01-30 13:43:06 +00:00
|
|
|
/**
|
|
|
|
* Notify external application (if API is enabled) that the screen sharing
|
|
|
|
* has been turned on/off.
|
|
|
|
*
|
|
|
|
* @param {boolean} on - True if screen sharing is enabled.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notifyScreenSharingStatusChanged(on: boolean) {
|
|
|
|
this._sendEvent({
|
|
|
|
name: 'screen-sharing-status-changed',
|
|
|
|
on
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:15:04 +00:00
|
|
|
/**
|
2017-04-17 15:52:31 +00:00
|
|
|
* Disposes the allocated resources.
|
2017-04-11 18:02:59 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2015-01-09 13:39:32 +00:00
|
|
|
*/
|
2017-04-11 18:02:59 +00:00
|
|
|
dispose() {
|
2017-04-27 20:21:01 +00:00
|
|
|
if (this._enabled) {
|
|
|
|
this._enabled = false;
|
2017-04-06 22:09:55 +00:00
|
|
|
APP.conference.removeListener(
|
|
|
|
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
2017-04-11 19:30:00 +00:00
|
|
|
onDesktopSharingEnabledChanged);
|
2017-04-06 22:09:55 +00:00
|
|
|
}
|
2015-01-09 13:39:32 +00:00
|
|
|
}
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default new API();
|