Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Comply w/ coding style
Lyubo Marinovf4de65a647ab
diff --git a/modules/API/API.js b/modules/API/API.jsindex 371180b666..555ea0c613 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -6,57 +6,33 @@ import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';/*** List of the available commands.- * @type {{- * displayName: inputDisplayNameHandler,- * toggleAudio: toggleAudio,- * toggleVideo: toggleVideo,- * toggleFilmStrip: toggleFilmStrip,- * toggleChat: toggleChat,- * toggleContactList: toggleContactList- * }}*/let commands = {};-const hashParams = getConfigParamsFromUrl();-/**- * JitsiMeetExternalAPI id - unique for a webpage.+ * 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.*/-const jitsiMeetExternalApiId = hashParams.jitsi_meet_external_api_id;+let initialScreenSharingState = false;/**- * Object that will execute sendMessage+ * JitsiMeetExternalAPI id - unique for a webpage.*/-const target = window.opener ? window.opener : window.parent;+const jitsiMeetExternalApiId+ = getConfigParamsFromUrl().jitsi_meet_external_api_id;/**- * Postis instance. Used to communicate with the external application.+ * Postis instance. Used to communicate with the external application. If+ * undefined, then API is disabled.*/let postis;/**- * Current status (enabled/disabled) of API.+ * Object that will execute sendMessage.*/-let enabled = false;--/**- * 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.- */-let initialScreenSharingState = false;--/**- * Executes on toggle-share-screen command.- */-function toggleScreenSharing() {- if(!APP.conference.isDesktopSharingEnabled) {- initialScreenSharingState = !initialScreenSharingState;- } else {- APP.conference.toggleScreenSharing();- }-}+const target = window.opener || window.parent;/*** Initializes supported commands.@@ -83,6 +59,19 @@ function initCommands() {key => postis.listen(key, args => commands[key](...args)));}+/**+ * 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();+ }+}+/*** Sends message to the external application.*@@ -90,7 +79,7 @@ function initCommands() {* @returns {void}*/function sendMessage(message) {- if (enabled) {+ if (postis) {postis.send(message);}}@@ -105,48 +94,47 @@ function shouldBeEnabled() {}/**- * Sends event object to the external application that has been subscribed- * for that event.+ * Executes on toggle-share-screen command.*- * @param {string} name - The name event.- * @param {Object} object - Data associated with the event.* @returns {void}*/-function triggerEvent(name, object) {- if (enabled) {- sendMessage({ method: name,- params: object });+function toggleScreenSharing() {+ if (APP.conference.isDesktopSharingEnabled) {+ APP.conference.toggleScreenSharing();+ } else {+ initialScreenSharingState = !initialScreenSharingState;}}/**- * Listens for screen sharing enabled events and toggles the screen sharing if- * needed.+ * Sends event object to the external application that has been subscribed for+ * that event.*- * @param {boolean} enabled - Current screen sharing enabled status.+ * @param {string} name - The name event.+ * @param {Object} object - Data associated with the event.* @returns {void}*/-function onScreenSharingEnable(enabled = false) {- if(enabled && initialScreenSharingState) {- toggleScreenSharing();- }+function triggerEvent(name, object) {+ sendMessage({+ method: name,+ params: object+ });}/**- * Implements API class that communicates with external api class- * and provides interface to access Jitsi Meet features by external- * applications that embed Jitsi Meet+ * Implements API class that communicates with external API class and provides+ * interface to access Jitsi Meet features by external applications that embed+ * Jitsi Meet.*/class API {/**- * Initializes the APIConnector. 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 APIConnector- * is initialized.+ * 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.** @param {Object} options - Optional parameters.- * @param {boolean} options.forceEnable - If true the module will be- * enabled.+ * @param {boolean} options.forceEnable - True to forcefully enable the+ * module.* @returns {void}*/init(options = {}) {@@ -154,14 +142,10 @@ class API {return;}- if(!enabled) {+ if (!postis) {APP.conference.addListener(JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,- onScreenSharingEnable);- enabled = true;- }-- if (!postis) {+ onDesktopSharingEnabledChanged);this._initPostis();}}@@ -197,8 +181,8 @@ class API {}/**- * Notify external application (if API is enabled) that- * message was received.+ * Notify external application (if API is enabled) that message was+ * received.** @param {Object} options - Object with the message properties.* @returns {void}@@ -212,16 +196,17 @@ class API {triggerEvent('incoming-message',- { 'from': id,- 'nick': nick,+ {+ 'from': id,'message': body,- 'stamp': ts }- );+ 'nick': nick,+ 'stamp': ts+ });}/**- * Notify external application (if API is enabled) that- * user joined the conference.+ * Notify external application (if API is enabled) that user joined the+ * conference.** @param {string} id - User id.* @returns {void}@@ -231,8 +216,8 @@ class API {}/**- * Notify external application (if API is enabled) that- * user left the conference.+ * Notify external application (if API is enabled) that user left the+ * conference.** @param {string} id - User id.* @returns {void}@@ -242,21 +227,25 @@ class API {}/**- * Notify external application (if API is enabled) that- * user changed their nickname.+ * Notify external application (if API is enabled) that user changed their+ * nickname.** @param {string} id - User id.* @param {string} displayName - User nickname.* @returns {void}*/notifyDisplayNameChanged(id, displayName) {- triggerEvent('display-name-change', { id,- displayname: displayName });+ triggerEvent(+ 'display-name-change',+ {+ displayname: displayName,+ id+ });}/**- * Notify external application (if API is enabled) that- * the conference has been joined.+ * Notify external application (if API is enabled) that the conference has+ * been joined.** @param {string} room - The room name.* @returns {void}@@ -266,8 +255,8 @@ class API {}/**- * Notify external application (if API is enabled) that- * user changed their nickname.+ * Notify external application (if API is enabled) that user changed their+ * nickname.** @param {string} room - User id.* @param {string} displayName - User nickname.@@ -278,8 +267,8 @@ class API {}/**- * Notify external application (if API is enabled) that- * we are ready to be closed.+ * Notify external application (if API is enabled) that we are ready to be+ * closed.** @returns {void}*/@@ -294,8 +283,10 @@ class API {* @returns {void}*/sendRemoteControlEvent(event) {- sendMessage({ method: 'remote-control-event',- params: event });+ sendMessage({+ method: 'remote-control-event',+ params: event+ });}/**@@ -304,11 +295,13 @@ class API {* @returns {void}*/dispose() {- if (enabled) {+ if (postis) {postis.destroy();+ postis = undefined;+APP.conference.removeListener(JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,- onScreenSharingEnable);+ onDesktopSharingEnabledChanged);}}}