2017-05-03 23:57:52 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { getLogger } from 'jitsi-meet-logger';
|
|
|
|
|
|
|
|
import * as KeyCodes from '../keycode/keycode';
|
2017-05-02 22:39:36 +00:00
|
|
|
import {
|
|
|
|
EVENT_TYPES,
|
|
|
|
PERMISSIONS_ACTIONS,
|
|
|
|
REMOTE_CONTROL_EVENT_NAME
|
2017-05-03 23:57:52 +00:00
|
|
|
} from '../../service/remotecontrol/Constants';
|
|
|
|
import UIEvents from '../../service/UI/UIEvents';
|
|
|
|
|
|
|
|
import RemoteControlParticipant from './RemoteControlParticipant';
|
|
|
|
|
|
|
|
declare var $: Function;
|
|
|
|
declare var APP: Object;
|
|
|
|
declare var JitsiMeetJS: Object;
|
2016-12-28 00:46:55 +00:00
|
|
|
|
|
|
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
2017-05-03 23:57:52 +00:00
|
|
|
const logger = getLogger(__filename);
|
2016-12-09 23:15:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract the keyboard key from the keyboard event.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {KeyboardEvent} event - The event.
|
|
|
|
* @returns {KEYS} The key that is pressed or undefined.
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
|
|
|
function getKey(event) {
|
|
|
|
return KeyCodes.keyboardEventToKey(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract the modifiers from the keyboard event.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {KeyboardEvent} event - The event.
|
|
|
|
* @returns {Array} With possible values: "shift", "control", "alt", "command".
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
|
|
|
function getModifiers(event) {
|
2017-05-03 23:57:52 +00:00
|
|
|
const modifiers = [];
|
|
|
|
|
|
|
|
if (event.shiftKey) {
|
|
|
|
modifiers.push('shift');
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
if (event.ctrlKey) {
|
|
|
|
modifiers.push('control');
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
if (event.altKey) {
|
|
|
|
modifiers.push('alt');
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
2017-05-03 23:57:52 +00:00
|
|
|
if (event.metaKey) {
|
|
|
|
modifiers.push('command');
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return modifiers;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class represents the controller party for a remote controller session.
|
|
|
|
* It listens for mouse and keyboard events and sends them to the receiver
|
|
|
|
* party of the remote control session.
|
|
|
|
*/
|
2016-12-28 00:46:55 +00:00
|
|
|
export default class Controller extends RemoteControlParticipant {
|
2017-05-03 23:57:52 +00:00
|
|
|
_area: ?Object;
|
|
|
|
_controlledParticipant: string | null;
|
|
|
|
_isCollectingEvents: boolean;
|
|
|
|
_largeVideoChangedListener: Function;
|
|
|
|
_requestedParticipant: string | null;
|
|
|
|
_stopListener: Function;
|
|
|
|
_userLeftListener: Function;
|
|
|
|
|
2016-12-09 23:15:04 +00:00
|
|
|
/**
|
|
|
|
* Creates new instance.
|
|
|
|
*/
|
2016-12-20 22:15:13 +00:00
|
|
|
constructor() {
|
2016-12-28 00:46:55 +00:00
|
|
|
super();
|
2017-05-03 23:57:52 +00:00
|
|
|
this._isCollectingEvents = false;
|
|
|
|
this._controlledParticipant = null;
|
|
|
|
this._requestedParticipant = null;
|
2017-01-06 01:18:07 +00:00
|
|
|
this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
|
|
|
|
this._userLeftListener = this._onUserLeft.bind(this);
|
2017-01-10 18:51:25 +00:00
|
|
|
this._largeVideoChangedListener
|
|
|
|
= this._onLargeVideoIdChanged.bind(this);
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-28 00:46:55 +00:00
|
|
|
* Requests permissions from the remote control receiver side.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} userId - The user id of the participant that will be
|
2016-12-28 00:46:55 +00:00
|
|
|
* requested.
|
2017-05-03 23:57:52 +00:00
|
|
|
* @param {JQuerySelector} eventCaptureArea - The area that is going to be
|
2017-01-20 20:26:25 +00:00
|
|
|
* used mouse and keyboard event capture.
|
2017-05-03 23:57:52 +00:00
|
|
|
* @returns {Promise<boolean>} Resolve values - true(accept), false(deny),
|
|
|
|
* null(the participant has left).
|
2016-12-20 22:15:13 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
requestPermissions(userId: string, eventCaptureArea: Object) {
|
|
|
|
if (!this.enabled) {
|
|
|
|
return Promise.reject(new Error('Remote control is disabled!'));
|
2016-12-28 00:46:55 +00:00
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
this._area = eventCaptureArea;// $("#largeVideoWrapper")
|
|
|
|
logger.log(`Requsting remote control permissions from: ${userId}`);
|
|
|
|
|
2016-12-28 00:46:55 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2017-05-03 23:57:52 +00:00
|
|
|
// eslint-disable-next-line prefer-const
|
|
|
|
let onUserLeft, permissionsReplyListener;
|
|
|
|
|
2017-01-06 01:18:07 +00:00
|
|
|
const clearRequest = () => {
|
2017-05-03 23:57:52 +00:00
|
|
|
this._requestedParticipant = null;
|
2017-01-06 01:18:07 +00:00
|
|
|
APP.conference.removeConferenceListener(
|
|
|
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
|
|
|
permissionsReplyListener);
|
|
|
|
APP.conference.removeConferenceListener(
|
|
|
|
ConferenceEvents.USER_LEFT,
|
|
|
|
onUserLeft);
|
|
|
|
};
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
permissionsReplyListener = (participant, event) => {
|
2016-12-28 00:46:55 +00:00
|
|
|
let result = null;
|
2017-05-03 23:57:52 +00:00
|
|
|
|
2016-12-28 00:46:55 +00:00
|
|
|
try {
|
|
|
|
result = this._handleReply(participant, event);
|
|
|
|
} catch (e) {
|
2017-05-03 23:57:52 +00:00
|
|
|
clearRequest();
|
2016-12-28 00:46:55 +00:00
|
|
|
reject(e);
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
if (result !== null) {
|
2017-01-06 01:18:07 +00:00
|
|
|
clearRequest();
|
2016-12-28 00:46:55 +00:00
|
|
|
resolve(result);
|
|
|
|
}
|
|
|
|
};
|
2017-05-03 23:57:52 +00:00
|
|
|
onUserLeft = id => {
|
|
|
|
if (id === this._requestedParticipant) {
|
2017-01-06 01:18:07 +00:00
|
|
|
clearRequest();
|
|
|
|
resolve(null);
|
|
|
|
}
|
|
|
|
};
|
2017-05-03 23:57:52 +00:00
|
|
|
|
2016-12-28 00:46:55 +00:00
|
|
|
APP.conference.addConferenceListener(
|
|
|
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
|
|
|
permissionsReplyListener);
|
2017-01-06 01:18:07 +00:00
|
|
|
APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
|
|
|
|
onUserLeft);
|
2017-05-03 23:57:52 +00:00
|
|
|
this._requestedParticipant = userId;
|
|
|
|
this.sendRemoteControlEvent(userId, {
|
2016-12-28 00:46:55 +00:00
|
|
|
type: EVENT_TYPES.permissions,
|
|
|
|
action: PERMISSIONS_ACTIONS.request
|
|
|
|
}, e => {
|
2017-01-06 01:18:07 +00:00
|
|
|
clearRequest();
|
2016-12-28 00:46:55 +00:00
|
|
|
reject(e);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the reply of the permissions request.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {JitsiParticipant} participant - The participant that has sent the
|
|
|
|
* reply.
|
|
|
|
* @param {RemoteControlEvent} event - The remote control event.
|
|
|
|
* @returns {void}
|
2016-12-28 00:46:55 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_handleReply(participant: Object, event: Object) {
|
2016-12-28 00:46:55 +00:00
|
|
|
const userId = participant.getId();
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
if (this.enabled
|
2017-05-02 22:39:36 +00:00
|
|
|
&& event.name === REMOTE_CONTROL_EVENT_NAME
|
|
|
|
&& event.type === EVENT_TYPES.permissions
|
2017-05-03 23:57:52 +00:00
|
|
|
&& userId === this._requestedParticipant) {
|
|
|
|
if (event.action !== PERMISSIONS_ACTIONS.grant) {
|
|
|
|
this._area = undefined;
|
2017-01-20 20:26:25 +00:00
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
switch (event.action) {
|
|
|
|
case PERMISSIONS_ACTIONS.grant: {
|
|
|
|
this._controlledParticipant = userId;
|
|
|
|
logger.log('Remote control permissions granted to:', userId);
|
|
|
|
this._start();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case PERMISSIONS_ACTIONS.deny:
|
|
|
|
return false;
|
|
|
|
case PERMISSIONS_ACTIONS.error:
|
|
|
|
throw new Error('Error occurred on receiver side');
|
|
|
|
default:
|
|
|
|
throw new Error('Unknown reply received!');
|
2016-12-28 00:46:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-05-03 23:57:52 +00:00
|
|
|
// different message type or another user -> ignoring the message
|
2016-12-28 00:46:55 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles remote control stopped.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {JitsiParticipant} participant - The participant that has sent the
|
|
|
|
* event.
|
|
|
|
* @param {Object} event - EndpointMessage event from the data channels.
|
|
|
|
* @property {string} type - The function process only events with
|
|
|
|
* name REMOTE_CONTROL_EVENT_NAME.
|
|
|
|
* @returns {void}
|
2016-12-28 00:46:55 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_handleRemoteControlStoppedEvent(participant: Object, event: Object) {
|
|
|
|
if (this.enabled
|
2017-05-02 22:39:36 +00:00
|
|
|
&& event.name === REMOTE_CONTROL_EVENT_NAME
|
|
|
|
&& event.type === EVENT_TYPES.stop
|
2017-05-03 23:57:52 +00:00
|
|
|
&& participant.getId() === this._controlledParticipant) {
|
2016-12-28 00:46:55 +00:00
|
|
|
this._stop();
|
|
|
|
}
|
2016-12-20 22:15:13 +00:00
|
|
|
}
|
2016-12-09 23:15:04 +00:00
|
|
|
|
|
|
|
/**
|
2017-01-10 18:51:25 +00:00
|
|
|
* Starts processing the mouse and keyboard events. Sets conference
|
|
|
|
* listeners. Disables keyboard events.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
2016-12-28 00:46:55 +00:00
|
|
|
_start() {
|
2017-05-03 23:57:52 +00:00
|
|
|
logger.log('Starting remote control controller.');
|
2017-01-10 18:51:25 +00:00
|
|
|
APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
|
|
|
this._largeVideoChangedListener);
|
2016-12-28 00:46:55 +00:00
|
|
|
APP.conference.addConferenceListener(
|
|
|
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
2017-01-06 01:18:07 +00:00
|
|
|
this._stopListener);
|
|
|
|
APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
|
|
|
|
this._userLeftListener);
|
2017-01-10 18:51:25 +00:00
|
|
|
this.resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables the keyboatd shortcuts. Starts collecting remote control
|
2017-05-03 23:57:52 +00:00
|
|
|
* events. It can be used to resume an active remote control session wchich
|
|
|
|
* was paused with this.pause().
|
2017-01-10 18:51:25 +00:00
|
|
|
*
|
2017-05-03 23:57:52 +00:00
|
|
|
* @returns {void}
|
2017-01-10 18:51:25 +00:00
|
|
|
*/
|
|
|
|
resume() {
|
2017-05-03 23:57:52 +00:00
|
|
|
if (!this.enabled || this._isCollectingEvents || !this._area) {
|
2017-01-10 18:51:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
logger.log('Resuming remote control controller.');
|
|
|
|
this._isCollectingEvents = true;
|
2017-01-10 18:51:25 +00:00
|
|
|
APP.keyboardshortcut.enable(false);
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.mousemove(event => {
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
const position = this._area.position();
|
|
|
|
|
|
|
|
this.sendRemoteControlEvent(this._controlledParticipant, {
|
2016-12-20 22:15:13 +00:00
|
|
|
type: EVENT_TYPES.mousemove,
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null
|
|
|
|
x: (event.pageX - position.left) / this._area.width(),
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null
|
|
|
|
y: (event.pageY - position.top) / this._area.height()
|
2016-12-09 23:15:04 +00:00
|
|
|
});
|
|
|
|
});
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.mousedown(this._onMouseClickHandler.bind(this,
|
2016-12-20 22:15:13 +00:00
|
|
|
EVENT_TYPES.mousedown));
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.mouseup(this._onMouseClickHandler.bind(this,
|
2016-12-20 22:15:13 +00:00
|
|
|
EVENT_TYPES.mouseup));
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.dblclick(
|
2016-12-20 22:15:13 +00:00
|
|
|
this._onMouseClickHandler.bind(this, EVENT_TYPES.mousedblclick));
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.contextmenu(() => false);
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area[0].onmousewheel = event => {
|
|
|
|
this.sendRemoteControlEvent(this._controlledParticipant, {
|
2016-12-20 22:15:13 +00:00
|
|
|
type: EVENT_TYPES.mousescroll,
|
2016-12-09 23:15:04 +00:00
|
|
|
x: event.deltaX,
|
|
|
|
y: event.deltaY
|
|
|
|
});
|
|
|
|
};
|
2016-12-20 22:15:13 +00:00
|
|
|
$(window).keydown(this._onKeyPessHandler.bind(this,
|
|
|
|
EVENT_TYPES.keydown));
|
|
|
|
$(window).keyup(this._onKeyPessHandler.bind(this, EVENT_TYPES.keyup));
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-06 01:18:07 +00:00
|
|
|
* Stops processing the mouse and keyboard events. Removes added listeners.
|
2017-01-10 18:51:25 +00:00
|
|
|
* Enables the keyboard shortcuts. Displays dialog to notify the user that
|
|
|
|
* remote control session has ended.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
2016-12-28 00:46:55 +00:00
|
|
|
_stop() {
|
2017-05-03 23:57:52 +00:00
|
|
|
if (!this._controlledParticipant) {
|
2017-01-06 01:18:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
logger.log('Stopping remote control controller.');
|
2017-01-10 18:51:25 +00:00
|
|
|
APP.UI.removeListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
|
|
|
this._largeVideoChangedListener);
|
2016-12-28 00:46:55 +00:00
|
|
|
APP.conference.removeConferenceListener(
|
|
|
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
2017-01-06 01:18:07 +00:00
|
|
|
this._stopListener);
|
|
|
|
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
|
|
|
this._userLeftListener);
|
2017-05-03 23:57:52 +00:00
|
|
|
this._controlledParticipant = null;
|
2017-01-10 18:51:25 +00:00
|
|
|
this.pause();
|
2017-05-03 23:57:52 +00:00
|
|
|
this._area = undefined;
|
2017-01-06 01:18:07 +00:00
|
|
|
APP.UI.messageHandler.openMessageDialog(
|
2017-05-03 23:57:52 +00:00
|
|
|
'dialog.remoteControlTitle',
|
|
|
|
'dialog.remoteControlStopMessage'
|
2017-01-06 01:18:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-03 23:57:52 +00:00
|
|
|
* Executes this._stop() mehtod which stops processing the mouse and
|
|
|
|
* keyboard events, removes added listeners, enables the keyboard shortcuts,
|
|
|
|
* displays dialog to notify the user that remote control session has ended.
|
|
|
|
* In addition sends stop message to the controlled participant.
|
2017-01-10 18:51:25 +00:00
|
|
|
*
|
2017-05-03 23:57:52 +00:00
|
|
|
* @returns {void}
|
2017-01-06 01:18:07 +00:00
|
|
|
*/
|
|
|
|
stop() {
|
2017-05-03 23:57:52 +00:00
|
|
|
if (!this._controlledParticipant) {
|
2017-01-06 01:18:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
this.sendRemoteControlEvent(this._controlledParticipant, {
|
2017-01-06 01:18:07 +00:00
|
|
|
type: EVENT_TYPES.stop
|
|
|
|
});
|
|
|
|
this._stop();
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 18:51:25 +00:00
|
|
|
/**
|
|
|
|
* Pauses the collecting of events and enables the keyboard shortcus. But
|
|
|
|
* it doesn't removes any other listeners. Basically the remote control
|
|
|
|
* session will be still active after this.pause(), but no events from the
|
2017-05-03 23:57:52 +00:00
|
|
|
* controller side will be captured and sent. You can resume the collecting
|
|
|
|
* of the events with this.resume().
|
2017-01-10 18:51:25 +00:00
|
|
|
*
|
2017-05-03 23:57:52 +00:00
|
|
|
* @returns {void}
|
2017-01-10 18:51:25 +00:00
|
|
|
*/
|
|
|
|
pause() {
|
2017-05-03 23:57:52 +00:00
|
|
|
if (!this._controlledParticipant) {
|
2017-01-10 18:51:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
logger.log('Pausing remote control controller.');
|
|
|
|
this._isCollectingEvents = false;
|
2017-01-10 18:51:25 +00:00
|
|
|
APP.keyboardshortcut.enable(true);
|
2017-05-03 23:57:52 +00:00
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.off('mousemove');
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.off('mousedown');
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.off('mouseup');
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.off('contextmenu');
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area.off('dblclick');
|
|
|
|
|
|
|
|
$(window).off('keydown');
|
|
|
|
$(window).off('keyup');
|
|
|
|
|
|
|
|
// $FlowDisableNextLine: we are sure that this._area is not null.
|
|
|
|
this._area[0].onmousewheel = undefined;
|
2017-01-10 18:51:25 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 23:15:04 +00:00
|
|
|
/**
|
|
|
|
* Handler for mouse click events.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} type - The type of event ("mousedown"/"mouseup").
|
|
|
|
* @param {Event} event - The mouse event.
|
|
|
|
* @returns {void}
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_onMouseClickHandler(type: string, event: Object) {
|
|
|
|
this.sendRemoteControlEvent(this._controlledParticipant, {
|
|
|
|
type,
|
2016-12-09 23:15:04 +00:00
|
|
|
button: event.which
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-01-06 01:18:07 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the remote control session is started.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
2017-01-06 01:18:07 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isStarted() {
|
2017-05-03 23:57:52 +00:00
|
|
|
return this._controlledParticipant !== null;
|
2017-01-06 01:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-03 23:57:52 +00:00
|
|
|
* Returns the id of the requested participant.
|
|
|
|
*
|
|
|
|
* @returns {string} The id of the requested participant.
|
2017-01-23 22:06:51 +00:00
|
|
|
* NOTE: This id should be the result of JitsiParticipant.getId() call.
|
2017-01-06 01:18:07 +00:00
|
|
|
*/
|
|
|
|
getRequestedParticipant() {
|
2017-05-03 23:57:52 +00:00
|
|
|
return this._requestedParticipant;
|
2017-01-06 01:18:07 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 23:15:04 +00:00
|
|
|
/**
|
|
|
|
* Handler for key press events.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} type - The type of event ("keydown"/"keyup").
|
|
|
|
* @param {Event} event - The key event.
|
|
|
|
* @returns {void}
|
2016-12-09 23:15:04 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_onKeyPessHandler(type: string, event: Object) {
|
|
|
|
this.sendRemoteControlEvent(this._controlledParticipant, {
|
|
|
|
type,
|
2016-12-09 23:15:04 +00:00
|
|
|
key: getKey(event),
|
2017-05-03 23:57:52 +00:00
|
|
|
modifiers: getModifiers(event)
|
2016-12-09 23:15:04 +00:00
|
|
|
});
|
|
|
|
}
|
2017-01-06 01:18:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls the stop method if the other side have left.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - The user id for the participant that have left.
|
|
|
|
* @returns {void}
|
2017-01-06 01:18:07 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_onUserLeft(id: string) {
|
|
|
|
if (this._controlledParticipant === id) {
|
2017-01-06 01:18:07 +00:00
|
|
|
this._stop();
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 18:51:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles changes of the participant displayed on the large video.
|
2017-05-03 23:57:52 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - The user id for the participant that is displayed.
|
|
|
|
* @returns {void}
|
2017-01-10 18:51:25 +00:00
|
|
|
*/
|
2017-05-03 23:57:52 +00:00
|
|
|
_onLargeVideoIdChanged(id: string) {
|
|
|
|
if (!this._controlledParticipant) {
|
2017-01-10 18:51:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-03 23:57:52 +00:00
|
|
|
if (this._controlledParticipant === id) {
|
2017-01-10 18:51:25 +00:00
|
|
|
this.resume();
|
|
|
|
} else {
|
|
|
|
this.pause();
|
|
|
|
}
|
|
|
|
}
|
2016-12-09 23:15:04 +00:00
|
|
|
}
|