From 0efca9a9a89f97514a79906eb5d0527933a06b7a Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Tue, 17 Jan 2017 18:16:18 -0600 Subject: [PATCH] fix(remotecontrol): Fixing issues after peer review. --- conference.js | 6 +++--- modules/API/API.js | 13 ++++++++++++- modules/keycode/keycode.js | 1 + modules/remotecontrol/Controller.js | 3 --- modules/remotecontrol/Receiver.js | 9 +++++++-- modules/remotecontrol/RemoteControl.js | 12 ++++++++++-- react/features/app/functions.web.js | 6 +++++- 7 files changed, 38 insertions(+), 12 deletions(-) diff --git a/conference.js b/conference.js index d198b354e..eb3472dd1 100644 --- a/conference.js +++ b/conference.js @@ -1838,9 +1838,9 @@ export default { /** * Sends a message via the data channel. - * @param to {string} the id of the endpoint that should receive the - * message. If "" the message will be sent to all participants. - * @param payload {object} the payload of the message. + * @param {string} to the id of the endpoint that should receive the + * message. If "" - the message will be sent to all participants. + * @param {object} payload the payload of the message. * @throws NetworkError or InvalidStateError or Error if the operation * fails. */ diff --git a/modules/API/API.js b/modules/API/API.js index 471ccfe48..fd53ed695 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -218,7 +218,18 @@ class API { /** * Sends remote control event. - * @param {object} event the event. + * @param {object} event the remote control event. The remote control event + * has one mandatory property - type which is string from EVENT_TYPES enum + * defined in /service/remotecontrol/constants. Depending on the event type + * the event can have other properties or not. + * mousemove - will also have {int} properties x and y + * mousedown, mouseup and mousedblclick - will have {int} property button + * with values - 1(left), 2(middle) or 3 (right) + * mousescroll - will have {int} property y + * keydown and keyup - will have {string} property key and array of strings + * property modifiers. + * stop - won't have any other properties + * permissions - will have {PERMISSIONS_ACTIONS} property action. */ sendRemoteControlEvent(event) { sendMessage({method: "remote-control-event", params: event}); diff --git a/modules/keycode/keycode.js b/modules/keycode/keycode.js index 94a81ba4b..b6f5c8d71 100644 --- a/modules/keycode/keycode.js +++ b/modules/keycode/keycode.js @@ -1,5 +1,6 @@ /** * Enumerates the supported keys. + * NOTE: The maps represents actual keys on the keyboard not chars. */ export const KEYS = { BACKSPACE: "backspace" , diff --git a/modules/remotecontrol/Controller.js b/modules/remotecontrol/Controller.js index aadcc0cbc..e5e885c68 100644 --- a/modules/remotecontrol/Controller.js +++ b/modules/remotecontrol/Controller.js @@ -170,9 +170,6 @@ export default class Controller extends RemoteControlParticipant { * listeners. Disables keyboard events. */ _start() { - if(!this.enabled) { - return; - } APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED, this._largeVideoChangedListener); APP.conference.addConferenceListener( diff --git a/modules/remotecontrol/Receiver.js b/modules/remotecontrol/Receiver.js index eeb1f1763..c1ccef848 100644 --- a/modules/remotecontrol/Receiver.js +++ b/modules/remotecontrol/Receiver.js @@ -86,9 +86,14 @@ export default class Receiver extends RemoteControlParticipant { } /** - * Sends "remote-control-event" events to to the API module. + * Listens for data channel EndpointMessage events. Handles only events of + * type remote control. Sends "remote-control-event" events to the API + * module. * @param {JitsiParticipant} participant the controller participant - * @param {Object} event the remote control event. + * @param {Object} event EndpointMessage event from the data channels. It + * has {string} type property. The function process only events of type + * REMOTE_CONTROL_EVENT_TYPE which will have event property(the remote + * control event) */ _onRemoteControlEvent(participant, event) { if(this.enabled && event.type === REMOTE_CONTROL_EVENT_TYPE) { diff --git a/modules/remotecontrol/RemoteControl.js b/modules/remotecontrol/RemoteControl.js index e00f8f1af..ed906a465 100644 --- a/modules/remotecontrol/RemoteControl.js +++ b/modules/remotecontrol/RemoteControl.js @@ -39,8 +39,16 @@ class RemoteControl { } /** - * Handles remote control events from the API module. - * @param {object} event the remote control event + * Handles remote control events from the API module. Currently only events + * with type = EVENT_TYPES.supported or EVENT_TYPES.permissions + * @param {object} event the remote control event. The remote control event + * has one mandatory property - type which is string from EVENT_TYPES enum + * defined in /service/remotecontrol/constants. If the event type is + * "supported" it won't have any other properties. If the event type is + * "permissions" the method will expect also the following properties: + * {string} userId - the user id of the participant that made the request + * for permissions + * {PERMISSIONS_ACTIONS} action the action related to the event. */ onRemoteControlAPIEvent(event) { switch(event.type) { diff --git a/react/features/app/functions.web.js b/react/features/app/functions.web.js index 77319fde8..22d161843 100644 --- a/react/features/app/functions.web.js +++ b/react/features/app/functions.web.js @@ -23,7 +23,11 @@ export function init() { APP.keyboardshortcut = KeyboardShortcut; APP.tokenData = getTokenData(); - APP.API.init(APP.tokenData.jwt ? {forceEnable: true} : undefined); + + // Force enable the API if jwt token is passed because most probably + // jitsi meet is displayed inside of wrapper that will need to communicate + // with jitsi meet. + APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined); APP.translation.init(settings.getLanguage()); }