feat(remotecontrol): Implements config option that removes the auth window by default

Use the auth dialog provided by Jitsi Meet instead.
This commit is contained in:
hristoterezov 2017-05-04 11:52:23 -05:00 committed by Saúl Ibarra Corretgé
parent 26727cf8d8
commit a94732fff5
4 changed files with 35 additions and 18 deletions

View file

@ -1,3 +1,13 @@
module.exports = {
jitsiMeetURL: "https://meet.jit.si/"
/**
* The URL of the Jitsi Meet deployment that will be used.
*/
jitsiMeetURL: "https://meet.jit.si/",
/**
* If true, the authorization of remote control will be handled by jitsi
* meet electron app. Otherwise the authorization will be handled in Jitsi
* Meet.
*/
handleRemoteControlAuthorization: false
};

View file

@ -25,7 +25,7 @@ module.exports = {
},
/**
* The type of remote control events sent trough the API module.
* The name of remote control events sent trough the API module.
*/
REMOTE_CONTROL_EVENT_TYPE: "remote-control-event"
REMOTE_CONTROL_EVENT_NAME: "remote-control-event"
};

View file

@ -1,6 +1,6 @@
let robot = require("robotjs");
const constants = require("../../modules/remotecontrol/constants");
const {EVENT_TYPES, PERMISSIONS_ACTIONS, REMOTE_CONTROL_EVENT_TYPE} = constants;
const {EVENT_TYPES, PERMISSIONS_ACTIONS, REMOTE_CONTROL_EVENT_NAME} = constants;
/**
* Attaching to the window for debug purposes.
@ -64,17 +64,21 @@ class RemoteControl {
/**
* Initializes the remote control functionality.
*/
init(channel, windowManager) {
init(channel, windowManager, handleAuthorization) {
this.handleAuthorization = handleAuthorization;
this.windowManager = windowManager;
this.channel = channel;
this.channel.ready(() => {
this.channel.listen('message', message => {
const event = message.data;
if(event.name === REMOTE_CONTROL_EVENT_TYPE) {
if(event.name === REMOTE_CONTROL_EVENT_NAME) {
this.onRemoteControlEvent(event);
}
});
this.sendEvent({type: EVENT_TYPES.supported});
if (!handleAuthorization) {
this.start();
}
});
}
@ -177,16 +181,16 @@ class RemoteControl {
break;
}
case EVENT_TYPES.permissions: {
if(event.action !== PERMISSIONS_ACTIONS.request)
break;
//Open Dialog and answer
this.handlePermissionRequest({
userId: event.userId,
userJID: event.userJID,
displayName: event.displayName,
screenSharing: event.screenSharing
});
if(event.action === PERMISSIONS_ACTIONS.request
&& this.handleAuthorization) {
// Open Dialog and answer
this.handlePermissionRequest({
userId: event.userId,
userJID: event.userJID,
displayName: event.displayName,
screenSharing: event.screenSharing
});
}
break;
}
case EVENT_TYPES.stop: {
@ -204,7 +208,7 @@ class RemoteControl {
*/
sendEvent(event) {
const remoteControlEvent = Object.assign(
{ name: REMOTE_CONTROL_EVENT_TYPE },
{ name: REMOTE_CONTROL_EVENT_NAME },
event
);
this.channel.send({

View file

@ -78,7 +78,10 @@ function onload() {
window: iframe.contentWindow,
windowForEventListening: window
});
remoteControl.init(channel, dialogFactory);
remoteControl.init(
channel,
dialogFactory,
config.handleRemoteControlAuthorization);
}
/**