2017-05-03 23:57:52 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { getLogger } from 'jitsi-meet-logger';
|
2017-05-02 22:39:36 +00:00
|
|
|
|
2017-04-17 19:59:24 +00:00
|
|
|
import { DISCO_REMOTE_CONTROL_FEATURE }
|
|
|
|
from '../../service/remotecontrol/Constants';
|
|
|
|
|
|
|
|
import Controller from './Controller';
|
|
|
|
import Receiver from './Receiver';
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
const logger = getLogger(__filename);
|
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
declare var config: Object;
|
2016-12-20 22:15:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements the remote control functionality.
|
|
|
|
*/
|
|
|
|
class RemoteControl {
|
2017-05-03 23:57:52 +00:00
|
|
|
_initialized: boolean;
|
|
|
|
controller: Controller;
|
|
|
|
receiver: Receiver;
|
|
|
|
|
2016-12-20 22:15:13 +00:00
|
|
|
/**
|
|
|
|
* Constructs new instance. Creates controller and receiver properties.
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
this.controller = new Controller();
|
2017-05-03 23:57:52 +00:00
|
|
|
this._initialized = false;
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the remote control - checks if the remote control should be
|
2017-04-17 19:59:24 +00:00
|
|
|
* enabled or not.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-12-20 22:15:13 +00:00
|
|
|
*/
|
|
|
|
init() {
|
2017-05-03 23:57:52 +00:00
|
|
|
if (config.disableRemoteControl
|
|
|
|
|| this._initialized
|
2017-04-27 20:21:01 +00:00
|
|
|
|| !APP.conference.isDesktopSharingEnabled) {
|
2016-12-20 22:15:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
logger.log('Initializing remote control.');
|
|
|
|
this._initialized = true;
|
2016-12-20 22:15:13 +00:00
|
|
|
this.controller.enable(true);
|
2017-04-17 19:59:24 +00:00
|
|
|
this.receiver = new Receiver();
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2017-01-06 01:18:07 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-03 23:57:52 +00:00
|
|
|
* Checks whether the passed user supports remote control or not.
|
|
|
|
*
|
|
|
|
* @param {JitsiParticipant} user - The user to be tested.
|
|
|
|
* @returns {Promise<boolean>} The promise will be resolved with true if
|
2017-01-06 01:18:07 +00:00
|
|
|
* the user supports remote control and with false if not.
|
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
checkUserRemoteControlSupport(user: Object) {
|
2017-04-27 20:21:01 +00:00
|
|
|
return user.getFeatures().then(
|
|
|
|
features => features.has(DISCO_REMOTE_CONTROL_FEATURE),
|
2017-05-02 22:39:36 +00:00
|
|
|
() => false);
|
2017-01-06 01:18:07 +00:00
|
|
|
}
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default new RemoteControl();
|