diff --git a/modules/API/API.js b/modules/API/API.js index a9c50c76f..b41f847f2 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -127,18 +127,14 @@ class API { } /** - * Sends message to the external application. + * Sends event to the external application. * - * @param {string} name - The name of the event. - * @param {Object} data - The data to be sent. + * @param {Object} event - The event to be sent. * @returns {void} */ - _sendEvent(name, data = {}) { + _sendEvent(event = {}) { if (this._enabled) { - transport.sendEvent({ - data, - name - }); + transport.sendEvent(event); } } @@ -149,7 +145,10 @@ class API { * @returns {void} */ notifySendingChatMessage(message) { - this._sendEvent('outgoing-message', { message }); + this._sendEvent({ + name: 'outgoing-message', + message + }); } /** @@ -164,7 +163,8 @@ class API { return; } - this._sendEvent('incoming-message', { + this._sendEvent({ + name: 'incoming-message', from: id, message: body, nick, @@ -180,7 +180,10 @@ class API { * @returns {void} */ notifyUserJoined(id) { - this._sendEvent('participant-joined', { id }); + this._sendEvent({ + name: 'participant-joined', + id + }); } /** @@ -191,7 +194,10 @@ class API { * @returns {void} */ notifyUserLeft(id) { - this._sendEvent('participant-left', { id }); + this._sendEvent({ + name: 'participant-left', + id + }); } /** @@ -203,7 +209,7 @@ class API { * @returns {void} */ notifyDisplayNameChanged(id, displayname) { - this._sendEvent('display-name-change', { + this._sendEvent({ name: 'display-name-change', displayname, id }); @@ -217,7 +223,10 @@ class API { * @returns {void} */ notifyConferenceJoined(roomName) { - this._sendEvent('video-conference-joined', { roomName }); + this._sendEvent({ + name: 'video-conference-joined', + roomName + }); } /** @@ -228,7 +237,10 @@ class API { * @returns {void} */ notifyConferenceLeft(roomName) { - this._sendEvent('video-conference-left', { roomName }); + this._sendEvent({ + name: 'video-conference-left', + roomName + }); } /** @@ -238,7 +250,7 @@ class API { * @returns {void} */ notifyReadyToClose() { - this._sendEvent('video-ready-to-close', {}); + this._sendEvent({ name: 'video-ready-to-close' }); } /** diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index b72dc05a4..a2e40867b 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -234,7 +234,7 @@ class JitsiMeetExternalAPI extends EventEmitter { */ _setupListeners() { - this._transport.on('event', ({ data, name }) => { + this._transport.on('event', ({ name, ...data }) => { if (name === 'participant-joined') { changeParticipantNumber(this, 1); } else if (name === 'participant-left') { diff --git a/modules/transport/PostMessageTransportBackend.js b/modules/transport/PostMessageTransportBackend.js index ffdf2b180..d0a72d0a0 100644 --- a/modules/transport/PostMessageTransportBackend.js +++ b/modules/transport/PostMessageTransportBackend.js @@ -123,7 +123,7 @@ export default class PostMessageTransportBackend { * @param {Object} legacyMessage - The message to be sent. * @returns {void} */ - _sendLegacyMessage({ data, name }) { + _sendLegacyMessage({ name, ...data }) { if (name && LEGACY_OUTGOING_METHODS.indexOf(name) !== -1) { this.postis.send({ method: name,