fix(iframe_api): Remove enable/disable events
This commit is contained in:
parent
09d63d38ab
commit
4a5a1cd5f4
|
@ -1,5 +1,4 @@
|
||||||
/* global APP, getConfigParamsFromUrl */
|
/* global APP, getConfigParamsFromUrl */
|
||||||
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements API class that communicates with external api class
|
* Implements API class that communicates with external api class
|
||||||
|
@ -63,31 +62,6 @@ function initCommands() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maps the supported events and their status
|
|
||||||
* (true it the event is enabled and false if it is disabled)
|
|
||||||
* @type {{
|
|
||||||
* incoming-message: boolean,
|
|
||||||
* outgoing-message: boolean,
|
|
||||||
* display-name-change: boolean,
|
|
||||||
* participant-left: boolean,
|
|
||||||
* participant-joined: boolean,
|
|
||||||
* video-conference-left: boolean,
|
|
||||||
* video-conference-joined: boolean
|
|
||||||
* }}
|
|
||||||
*/
|
|
||||||
const events = {
|
|
||||||
"incoming-message": false,
|
|
||||||
"outgoing-message":false,
|
|
||||||
"display-name-change": false,
|
|
||||||
"participant-joined": false,
|
|
||||||
"participant-left": false,
|
|
||||||
"video-conference-joined": false,
|
|
||||||
"video-conference-left": false,
|
|
||||||
"video-ready-to-close": false
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends message to the external application.
|
* Sends message to the external application.
|
||||||
* @param message {object}
|
* @param message {object}
|
||||||
|
@ -95,27 +69,19 @@ const events = {
|
||||||
* @param params {object} the object that will be sent as JSON string
|
* @param params {object} the object that will be sent as JSON string
|
||||||
*/
|
*/
|
||||||
function sendMessage(message) {
|
function sendMessage(message) {
|
||||||
if(enabled)
|
if(enabled) {
|
||||||
postis.send(message);
|
postis.send(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the API should be enabled or not.
|
* Check whether the API should be enabled or not.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function isEnabled () {
|
function shouldBeEnabled () {
|
||||||
return (typeof jitsi_meet_external_api_id === "number");
|
return (typeof jitsi_meet_external_api_id === "number");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the event is enabled ot not.
|
|
||||||
* @param name the name of the event.
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
function isEventEnabled (name) {
|
|
||||||
return events[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends event object to the external application that has been subscribed
|
* Sends event object to the external application that has been subscribed
|
||||||
* for that event.
|
* for that event.
|
||||||
|
@ -123,25 +89,8 @@ function isEventEnabled (name) {
|
||||||
* @param object data associated with the event
|
* @param object data associated with the event
|
||||||
*/
|
*/
|
||||||
function triggerEvent (name, object) {
|
function triggerEvent (name, object) {
|
||||||
if(isEventEnabled(name))
|
if(enabled) {
|
||||||
sendMessage({method: name, params: object});
|
sendMessage({method: name, params: object});
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles system messages. (for example: enable/disable events)
|
|
||||||
* @param message {object} the message
|
|
||||||
*/
|
|
||||||
function onSystemMessage(message) {
|
|
||||||
switch (message.type) {
|
|
||||||
case "eventStatus":
|
|
||||||
if(!message.name || !message.value) {
|
|
||||||
logger.warn("Unknown system message format", message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
events[message.name] = message.value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger.warn("Unknown system message type", message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,17 +102,12 @@ export default {
|
||||||
* is initialized.
|
* is initialized.
|
||||||
* @param options {object}
|
* @param options {object}
|
||||||
* @param forceEnable {boolean} if true the module will be enabled.
|
* @param forceEnable {boolean} if true the module will be enabled.
|
||||||
* @param enabledEvents {array} array of events that should be enabled.
|
|
||||||
*/
|
*/
|
||||||
init (options = {}) {
|
init (options = {}) {
|
||||||
if(!isEnabled() && !options.forceEnable)
|
if(!shouldBeEnabled() && !options.forceEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
enabled = true;
|
enabled = true;
|
||||||
if(options.enabledEvents)
|
|
||||||
options.enabledEvents.forEach(function (eventName) {
|
|
||||||
events[eventName] = true;
|
|
||||||
});
|
|
||||||
let postisOptions = {
|
let postisOptions = {
|
||||||
window: target
|
window: target
|
||||||
};
|
};
|
||||||
|
@ -171,7 +115,6 @@ export default {
|
||||||
postisOptions.scope
|
postisOptions.scope
|
||||||
= "jitsi_meet_external_api_" + jitsi_meet_external_api_id;
|
= "jitsi_meet_external_api_" + jitsi_meet_external_api_id;
|
||||||
postis = postisInit(postisOptions);
|
postis = postisInit(postisOptions);
|
||||||
postis.listen("jitsiSystemMessage", onSystemMessage);
|
|
||||||
initCommands();
|
initCommands();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -68,23 +68,6 @@ function sendMessage(postis, object) {
|
||||||
postis.send(object);
|
postis.send(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends message for event enable/disable status change.
|
|
||||||
* @param postis {Postis object} the postis instance that is going to be used.
|
|
||||||
* @param event {string} the name of the event
|
|
||||||
* @param status {boolean} true - enabled; false - disabled;
|
|
||||||
*/
|
|
||||||
function changeEventStatus(postis, event, status) {
|
|
||||||
if(!(event in events)) {
|
|
||||||
logger.error("Not supported event name.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendMessage(postis, {
|
|
||||||
method: "jitsiSystemMessage",
|
|
||||||
params: {type: "eventStatus", name: events[event], value: status}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds given number to the numberOfParticipants property of given APIInstance.
|
* Adds given number to the numberOfParticipants property of given APIInstance.
|
||||||
* @param {JitsiMeetExternalAPI} APIInstance the instance of the
|
* @param {JitsiMeetExternalAPI} APIInstance the instance of the
|
||||||
|
@ -340,7 +323,6 @@ JitsiMeetExternalAPI.prototype.addEventListener = function(event, listener) {
|
||||||
this.postisListeners[event] = true;
|
this.postisListeners[event] = true;
|
||||||
}
|
}
|
||||||
this.eventHandlers[event] = listener;
|
this.eventHandlers[event] = listener;
|
||||||
changeEventStatus(this.postis, event, true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,7 +336,6 @@ JitsiMeetExternalAPI.prototype.removeEventListener = function(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete this.eventHandlers[event];
|
delete this.eventHandlers[event];
|
||||||
changeEventStatus(this.postis, event, false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,9 +75,7 @@ class TokenData{
|
||||||
|
|
||||||
//External API settings
|
//External API settings
|
||||||
this.externalAPISettings = {
|
this.externalAPISettings = {
|
||||||
forceEnable: true,
|
forceEnable: true
|
||||||
enabledEvents: ["video-conference-joined", "video-conference-left",
|
|
||||||
"video-ready-to-close"]
|
|
||||||
};
|
};
|
||||||
this._decode();
|
this._decode();
|
||||||
// Use JWT param as token if there is not other token set and if the
|
// Use JWT param as token if there is not other token set and if the
|
||||||
|
|
Loading…
Reference in New Issue