|
@@ -1,5 +1,4 @@
|
1
|
1
|
/* global APP, getConfigParamsFromUrl */
|
2
|
|
-const logger = require("jitsi-meet-logger").getLogger(__filename);
|
3
|
2
|
|
4
|
3
|
/**
|
5
|
4
|
* Implements API class that communicates with external api class
|
|
@@ -63,31 +62,6 @@ function initCommands() {
|
63
|
62
|
});
|
64
|
63
|
}
|
65
|
64
|
|
66
|
|
-
|
67
|
|
-/**
|
68
|
|
- * Maps the supported events and their status
|
69
|
|
- * (true it the event is enabled and false if it is disabled)
|
70
|
|
- * @type {{
|
71
|
|
- * incoming-message: boolean,
|
72
|
|
- * outgoing-message: boolean,
|
73
|
|
- * display-name-change: boolean,
|
74
|
|
- * participant-left: boolean,
|
75
|
|
- * participant-joined: boolean,
|
76
|
|
- * video-conference-left: boolean,
|
77
|
|
- * video-conference-joined: boolean
|
78
|
|
- * }}
|
79
|
|
- */
|
80
|
|
-const events = {
|
81
|
|
- "incoming-message": false,
|
82
|
|
- "outgoing-message":false,
|
83
|
|
- "display-name-change": false,
|
84
|
|
- "participant-joined": false,
|
85
|
|
- "participant-left": false,
|
86
|
|
- "video-conference-joined": false,
|
87
|
|
- "video-conference-left": false,
|
88
|
|
- "video-ready-to-close": false
|
89
|
|
-};
|
90
|
|
-
|
91
|
65
|
/**
|
92
|
66
|
* Sends message to the external application.
|
93
|
67
|
* @param message {object}
|
|
@@ -95,27 +69,19 @@ const events = {
|
95
|
69
|
* @param params {object} the object that will be sent as JSON string
|
96
|
70
|
*/
|
97
|
71
|
function sendMessage(message) {
|
98
|
|
- if(enabled)
|
|
72
|
+ if(enabled) {
|
99
|
73
|
postis.send(message);
|
|
74
|
+ }
|
100
|
75
|
}
|
101
|
76
|
|
102
|
77
|
/**
|
103
|
78
|
* Check whether the API should be enabled or not.
|
104
|
79
|
* @returns {boolean}
|
105
|
80
|
*/
|
106
|
|
-function isEnabled () {
|
|
81
|
+function shouldBeEnabled () {
|
107
|
82
|
return (typeof jitsi_meet_external_api_id === "number");
|
108
|
83
|
}
|
109
|
84
|
|
110
|
|
-/**
|
111
|
|
- * Checks whether the event is enabled ot not.
|
112
|
|
- * @param name the name of the event.
|
113
|
|
- * @returns {*}
|
114
|
|
- */
|
115
|
|
-function isEventEnabled (name) {
|
116
|
|
- return events[name];
|
117
|
|
-}
|
118
|
|
-
|
119
|
85
|
/**
|
120
|
86
|
* Sends event object to the external application that has been subscribed
|
121
|
87
|
* for that event.
|
|
@@ -123,25 +89,8 @@ function isEventEnabled (name) {
|
123
|
89
|
* @param object data associated with the event
|
124
|
90
|
*/
|
125
|
91
|
function triggerEvent (name, object) {
|
126
|
|
- if(isEventEnabled(name))
|
|
92
|
+ if(enabled) {
|
127
|
93
|
sendMessage({method: name, params: object});
|
128
|
|
-}
|
129
|
|
-
|
130
|
|
-/**
|
131
|
|
- * Handles system messages. (for example: enable/disable events)
|
132
|
|
- * @param message {object} the message
|
133
|
|
- */
|
134
|
|
-function onSystemMessage(message) {
|
135
|
|
- switch (message.type) {
|
136
|
|
- case "eventStatus":
|
137
|
|
- if(!message.name || !message.value) {
|
138
|
|
- logger.warn("Unknown system message format", message);
|
139
|
|
- break;
|
140
|
|
- }
|
141
|
|
- events[message.name] = message.value;
|
142
|
|
- break;
|
143
|
|
- default:
|
144
|
|
- logger.warn("Unknown system message type", message);
|
145
|
94
|
}
|
146
|
95
|
}
|
147
|
96
|
|
|
@@ -153,17 +102,12 @@ export default {
|
153
|
102
|
* is initialized.
|
154
|
103
|
* @param options {object}
|
155
|
104
|
* @param forceEnable {boolean} if true the module will be enabled.
|
156
|
|
- * @param enabledEvents {array} array of events that should be enabled.
|
157
|
105
|
*/
|
158
|
106
|
init (options = {}) {
|
159
|
|
- if(!isEnabled() && !options.forceEnable)
|
|
107
|
+ if(!shouldBeEnabled() && !options.forceEnable)
|
160
|
108
|
return;
|
161
|
109
|
|
162
|
110
|
enabled = true;
|
163
|
|
- if(options.enabledEvents)
|
164
|
|
- options.enabledEvents.forEach(function (eventName) {
|
165
|
|
- events[eventName] = true;
|
166
|
|
- });
|
167
|
111
|
let postisOptions = {
|
168
|
112
|
window: target
|
169
|
113
|
};
|
|
@@ -171,7 +115,6 @@ export default {
|
171
|
115
|
postisOptions.scope
|
172
|
116
|
= "jitsi_meet_external_api_" + jitsi_meet_external_api_id;
|
173
|
117
|
postis = postisInit(postisOptions);
|
174
|
|
- postis.listen("jitsiSystemMessage", onSystemMessage);
|
175
|
118
|
initCommands();
|
176
|
119
|
},
|
177
|
120
|
|