|
@@ -1,20 +1,29 @@
|
1
|
|
-/* global $, JitsiMeetJS, APP */
|
2
|
|
-const logger = require("jitsi-meet-logger").getLogger(__filename);
|
3
|
|
-import * as KeyCodes from "../keycode/keycode";
|
|
1
|
+/* @flow */
|
|
2
|
+
|
|
3
|
+import { getLogger } from 'jitsi-meet-logger';
|
|
4
|
+
|
|
5
|
+import * as KeyCodes from '../keycode/keycode';
|
4
|
6
|
import {
|
5
|
7
|
EVENT_TYPES,
|
6
|
8
|
PERMISSIONS_ACTIONS,
|
7
|
9
|
REMOTE_CONTROL_EVENT_NAME
|
8
|
|
-} from "../../service/remotecontrol/Constants";
|
9
|
|
-import RemoteControlParticipant from "./RemoteControlParticipant";
|
10
|
|
-import UIEvents from "../../service/UI/UIEvents";
|
|
10
|
+} from '../../service/remotecontrol/Constants';
|
|
11
|
+import UIEvents from '../../service/UI/UIEvents';
|
|
12
|
+
|
|
13
|
+import RemoteControlParticipant from './RemoteControlParticipant';
|
|
14
|
+
|
|
15
|
+declare var $: Function;
|
|
16
|
+declare var APP: Object;
|
|
17
|
+declare var JitsiMeetJS: Object;
|
11
|
18
|
|
12
|
19
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
|
20
|
+const logger = getLogger(__filename);
|
13
|
21
|
|
14
|
22
|
/**
|
15
|
23
|
* Extract the keyboard key from the keyboard event.
|
16
|
|
- * @param event {KeyboardEvent} the event.
|
17
|
|
- * @returns {KEYS} the key that is pressed or undefined.
|
|
24
|
+ *
|
|
25
|
+ * @param {KeyboardEvent} event - The event.
|
|
26
|
+ * @returns {KEYS} The key that is pressed or undefined.
|
18
|
27
|
*/
|
19
|
28
|
function getKey(event) {
|
20
|
29
|
return KeyCodes.keyboardEventToKey(event);
|
|
@@ -22,26 +31,28 @@ function getKey(event) {
|
22
|
31
|
|
23
|
32
|
/**
|
24
|
33
|
* Extract the modifiers from the keyboard event.
|
25
|
|
- * @param event {KeyboardEvent} the event.
|
26
|
|
- * @returns {Array} with possible values: "shift", "control", "alt", "command".
|
|
34
|
+ *
|
|
35
|
+ * @param {KeyboardEvent} event - The event.
|
|
36
|
+ * @returns {Array} With possible values: "shift", "control", "alt", "command".
|
27
|
37
|
*/
|
28
|
38
|
function getModifiers(event) {
|
29
|
|
- let modifiers = [];
|
30
|
|
- if(event.shiftKey) {
|
31
|
|
- modifiers.push("shift");
|
|
39
|
+ const modifiers = [];
|
|
40
|
+
|
|
41
|
+ if (event.shiftKey) {
|
|
42
|
+ modifiers.push('shift');
|
32
|
43
|
}
|
33
|
44
|
|
34
|
|
- if(event.ctrlKey) {
|
35
|
|
- modifiers.push("control");
|
|
45
|
+ if (event.ctrlKey) {
|
|
46
|
+ modifiers.push('control');
|
36
|
47
|
}
|
37
|
48
|
|
38
|
49
|
|
39
|
|
- if(event.altKey) {
|
40
|
|
- modifiers.push("alt");
|
|
50
|
+ if (event.altKey) {
|
|
51
|
+ modifiers.push('alt');
|
41
|
52
|
}
|
42
|
53
|
|
43
|
|
- if(event.metaKey) {
|
44
|
|
- modifiers.push("command");
|
|
54
|
+ if (event.metaKey) {
|
|
55
|
+ modifiers.push('command');
|
45
|
56
|
}
|
46
|
57
|
|
47
|
58
|
return modifiers;
|
|
@@ -53,14 +64,22 @@ function getModifiers(event) {
|
53
|
64
|
* party of the remote control session.
|
54
|
65
|
*/
|
55
|
66
|
export default class Controller extends RemoteControlParticipant {
|
|
67
|
+ _area: ?Object;
|
|
68
|
+ _controlledParticipant: string | null;
|
|
69
|
+ _isCollectingEvents: boolean;
|
|
70
|
+ _largeVideoChangedListener: Function;
|
|
71
|
+ _requestedParticipant: string | null;
|
|
72
|
+ _stopListener: Function;
|
|
73
|
+ _userLeftListener: Function;
|
|
74
|
+
|
56
|
75
|
/**
|
57
|
76
|
* Creates new instance.
|
58
|
77
|
*/
|
59
|
78
|
constructor() {
|
60
|
79
|
super();
|
61
|
|
- this.isCollectingEvents = false;
|
62
|
|
- this.controlledParticipant = null;
|
63
|
|
- this.requestedParticipant = null;
|
|
80
|
+ this._isCollectingEvents = false;
|
|
81
|
+ this._controlledParticipant = null;
|
|
82
|
+ this._requestedParticipant = null;
|
64
|
83
|
this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
|
65
|
84
|
this._userLeftListener = this._onUserLeft.bind(this);
|
66
|
85
|
this._largeVideoChangedListener
|
|
@@ -69,24 +88,28 @@ export default class Controller extends RemoteControlParticipant {
|
69
|
88
|
|
70
|
89
|
/**
|
71
|
90
|
* Requests permissions from the remote control receiver side.
|
72
|
|
- * @param {string} userId the user id of the participant that will be
|
|
91
|
+ *
|
|
92
|
+ * @param {string} userId - The user id of the participant that will be
|
73
|
93
|
* requested.
|
74
|
|
- * @param {JQuerySelector} eventCaptureArea the area that is going to be
|
|
94
|
+ * @param {JQuerySelector} eventCaptureArea - The area that is going to be
|
75
|
95
|
* used mouse and keyboard event capture.
|
76
|
|
- * @returns {Promise<boolean>} - resolve values:
|
77
|
|
- * true - accept
|
78
|
|
- * false - deny
|
79
|
|
- * null - the participant has left.
|
|
96
|
+ * @returns {Promise<boolean>} Resolve values - true(accept), false(deny),
|
|
97
|
+ * null(the participant has left).
|
80
|
98
|
*/
|
81
|
|
- requestPermissions(userId, eventCaptureArea) {
|
82
|
|
- if(!this.enabled) {
|
83
|
|
- return Promise.reject(new Error("Remote control is disabled!"));
|
|
99
|
+ requestPermissions(userId: string, eventCaptureArea: Object) {
|
|
100
|
+ if (!this.enabled) {
|
|
101
|
+ return Promise.reject(new Error('Remote control is disabled!'));
|
84
|
102
|
}
|
85
|
|
- this.area = eventCaptureArea;// $("#largeVideoWrapper")
|
86
|
|
- logger.log("Requsting remote control permissions from: " + userId);
|
|
103
|
+
|
|
104
|
+ this._area = eventCaptureArea;// $("#largeVideoWrapper")
|
|
105
|
+ logger.log(`Requsting remote control permissions from: ${userId}`);
|
|
106
|
+
|
87
|
107
|
return new Promise((resolve, reject) => {
|
|
108
|
+ // eslint-disable-next-line prefer-const
|
|
109
|
+ let onUserLeft, permissionsReplyListener;
|
|
110
|
+
|
88
|
111
|
const clearRequest = () => {
|
89
|
|
- this.requestedParticipant = null;
|
|
112
|
+ this._requestedParticipant = null;
|
90
|
113
|
APP.conference.removeConferenceListener(
|
91
|
114
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
92
|
115
|
permissionsReplyListener);
|
|
@@ -94,31 +117,35 @@ export default class Controller extends RemoteControlParticipant {
|
94
|
117
|
ConferenceEvents.USER_LEFT,
|
95
|
118
|
onUserLeft);
|
96
|
119
|
};
|
97
|
|
- const permissionsReplyListener = (participant, event) => {
|
|
120
|
+
|
|
121
|
+ permissionsReplyListener = (participant, event) => {
|
98
|
122
|
let result = null;
|
|
123
|
+
|
99
|
124
|
try {
|
100
|
125
|
result = this._handleReply(participant, event);
|
101
|
126
|
} catch (e) {
|
|
127
|
+ clearRequest();
|
102
|
128
|
reject(e);
|
103
|
129
|
}
|
104
|
|
- if(result !== null) {
|
|
130
|
+ if (result !== null) {
|
105
|
131
|
clearRequest();
|
106
|
132
|
resolve(result);
|
107
|
133
|
}
|
108
|
134
|
};
|
109
|
|
- const onUserLeft = (id) => {
|
110
|
|
- if(id === this.requestedParticipant) {
|
|
135
|
+ onUserLeft = id => {
|
|
136
|
+ if (id === this._requestedParticipant) {
|
111
|
137
|
clearRequest();
|
112
|
138
|
resolve(null);
|
113
|
139
|
}
|
114
|
140
|
};
|
|
141
|
+
|
115
|
142
|
APP.conference.addConferenceListener(
|
116
|
143
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
117
|
144
|
permissionsReplyListener);
|
118
|
145
|
APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
|
119
|
146
|
onUserLeft);
|
120
|
|
- this.requestedParticipant = userId;
|
121
|
|
- this._sendRemoteControlEvent(userId, {
|
|
147
|
+ this._requestedParticipant = userId;
|
|
148
|
+ this.sendRemoteControlEvent(userId, {
|
122
|
149
|
type: EVENT_TYPES.permissions,
|
123
|
150
|
action: PERMISSIONS_ACTIONS.request
|
124
|
151
|
}, e => {
|
|
@@ -130,54 +157,58 @@ export default class Controller extends RemoteControlParticipant {
|
130
|
157
|
|
131
|
158
|
/**
|
132
|
159
|
* Handles the reply of the permissions request.
|
133
|
|
- * @param {JitsiParticipant} participant the participant that has sent the
|
134
|
|
- * reply
|
135
|
|
- * @param {RemoteControlEvent} event the remote control event.
|
|
160
|
+ *
|
|
161
|
+ * @param {JitsiParticipant} participant - The participant that has sent the
|
|
162
|
+ * reply.
|
|
163
|
+ * @param {RemoteControlEvent} event - The remote control event.
|
|
164
|
+ * @returns {void}
|
136
|
165
|
*/
|
137
|
|
- _handleReply(participant, event) {
|
|
166
|
+ _handleReply(participant: Object, event: Object) {
|
138
|
167
|
const userId = participant.getId();
|
139
|
|
- if(this.enabled
|
|
168
|
+
|
|
169
|
+ if (this.enabled
|
140
|
170
|
&& event.name === REMOTE_CONTROL_EVENT_NAME
|
141
|
171
|
&& event.type === EVENT_TYPES.permissions
|
142
|
|
- && userId === this.requestedParticipant) {
|
143
|
|
- if(event.action !== PERMISSIONS_ACTIONS.grant) {
|
144
|
|
- this.area = null;
|
|
172
|
+ && userId === this._requestedParticipant) {
|
|
173
|
+ if (event.action !== PERMISSIONS_ACTIONS.grant) {
|
|
174
|
+ this._area = undefined;
|
145
|
175
|
}
|
146
|
|
- switch(event.action) {
|
147
|
|
- case PERMISSIONS_ACTIONS.grant: {
|
148
|
|
- this.controlledParticipant = userId;
|
149
|
|
- logger.log("Remote control permissions granted to: "
|
150
|
|
- + userId);
|
151
|
|
- this._start();
|
152
|
|
- return true;
|
153
|
|
- }
|
154
|
|
- case PERMISSIONS_ACTIONS.deny:
|
155
|
|
- return false;
|
156
|
|
- case PERMISSIONS_ACTIONS.error:
|
157
|
|
- throw new Error("Error occurred on receiver side");
|
158
|
|
- default:
|
159
|
|
- throw new Error("Unknown reply received!");
|
|
176
|
+ switch (event.action) {
|
|
177
|
+ case PERMISSIONS_ACTIONS.grant: {
|
|
178
|
+ this._controlledParticipant = userId;
|
|
179
|
+ logger.log('Remote control permissions granted to:', userId);
|
|
180
|
+ this._start();
|
|
181
|
+
|
|
182
|
+ return true;
|
|
183
|
+ }
|
|
184
|
+ case PERMISSIONS_ACTIONS.deny:
|
|
185
|
+ return false;
|
|
186
|
+ case PERMISSIONS_ACTIONS.error:
|
|
187
|
+ throw new Error('Error occurred on receiver side');
|
|
188
|
+ default:
|
|
189
|
+ throw new Error('Unknown reply received!');
|
160
|
190
|
}
|
161
|
191
|
} else {
|
162
|
|
- //different message type or another user -> ignoring the message
|
|
192
|
+ // different message type or another user -> ignoring the message
|
163
|
193
|
return null;
|
164
|
194
|
}
|
165
|
195
|
}
|
166
|
196
|
|
167
|
197
|
/**
|
168
|
198
|
* Handles remote control stopped.
|
169
|
|
- * @param {JitsiParticipant} participant the participant that has sent the
|
170
|
|
- * event
|
171
|
|
- * @param {Object} event EndpointMessage event from the data channels.
|
172
|
|
- * @property {string} type property. The function process only events with
|
173
|
|
- * name REMOTE_CONTROL_EVENT_NAME
|
174
|
|
- * @property {RemoteControlEvent} event - the remote control event.
|
|
199
|
+ *
|
|
200
|
+ * @param {JitsiParticipant} participant - The participant that has sent the
|
|
201
|
+ * event.
|
|
202
|
+ * @param {Object} event - EndpointMessage event from the data channels.
|
|
203
|
+ * @property {string} type - The function process only events with
|
|
204
|
+ * name REMOTE_CONTROL_EVENT_NAME.
|
|
205
|
+ * @returns {void}
|
175
|
206
|
*/
|
176
|
|
- _handleRemoteControlStoppedEvent(participant, event) {
|
177
|
|
- if(this.enabled
|
|
207
|
+ _handleRemoteControlStoppedEvent(participant: Object, event: Object) {
|
|
208
|
+ if (this.enabled
|
178
|
209
|
&& event.name === REMOTE_CONTROL_EVENT_NAME
|
179
|
210
|
&& event.type === EVENT_TYPES.stop
|
180
|
|
- && participant.getId() === this.controlledParticipant) {
|
|
211
|
+ && participant.getId() === this._controlledParticipant) {
|
181
|
212
|
this._stop();
|
182
|
213
|
}
|
183
|
214
|
}
|
|
@@ -185,9 +216,11 @@ export default class Controller extends RemoteControlParticipant {
|
185
|
216
|
/**
|
186
|
217
|
* Starts processing the mouse and keyboard events. Sets conference
|
187
|
218
|
* listeners. Disables keyboard events.
|
|
219
|
+ *
|
|
220
|
+ * @returns {void}
|
188
|
221
|
*/
|
189
|
222
|
_start() {
|
190
|
|
- logger.log("Starting remote control controller.");
|
|
223
|
+ logger.log('Starting remote control controller.');
|
191
|
224
|
APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
192
|
225
|
this._largeVideoChangedListener);
|
193
|
226
|
APP.conference.addConferenceListener(
|
|
@@ -200,35 +233,53 @@ export default class Controller extends RemoteControlParticipant {
|
200
|
233
|
|
201
|
234
|
/**
|
202
|
235
|
* Disables the keyboatd shortcuts. Starts collecting remote control
|
203
|
|
- * events.
|
|
236
|
+ * events. It can be used to resume an active remote control session wchich
|
|
237
|
+ * was paused with this.pause().
|
204
|
238
|
*
|
205
|
|
- * It can be used to resume an active remote control session wchich was
|
206
|
|
- * paused with this.pause().
|
|
239
|
+ * @returns {void}
|
207
|
240
|
*/
|
208
|
241
|
resume() {
|
209
|
|
- if(!this.enabled || this.isCollectingEvents) {
|
|
242
|
+ if (!this.enabled || this._isCollectingEvents || !this._area) {
|
210
|
243
|
return;
|
211
|
244
|
}
|
212
|
|
- logger.log("Resuming remote control controller.");
|
213
|
|
- this.isCollectingEvents = true;
|
|
245
|
+ logger.log('Resuming remote control controller.');
|
|
246
|
+ this._isCollectingEvents = true;
|
214
|
247
|
APP.keyboardshortcut.enable(false);
|
215
|
|
- this.area.mousemove(event => {
|
216
|
|
- const position = this.area.position();
|
217
|
|
- this._sendRemoteControlEvent(this.controlledParticipant, {
|
|
248
|
+
|
|
249
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
250
|
+ this._area.mousemove(event => {
|
|
251
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
252
|
+ const position = this._area.position();
|
|
253
|
+
|
|
254
|
+ this.sendRemoteControlEvent(this._controlledParticipant, {
|
218
|
255
|
type: EVENT_TYPES.mousemove,
|
219
|
|
- x: (event.pageX - position.left)/this.area.width(),
|
220
|
|
- y: (event.pageY - position.top)/this.area.height()
|
|
256
|
+
|
|
257
|
+ // $FlowDisableNextLine: we are sure that this._area is not null
|
|
258
|
+ x: (event.pageX - position.left) / this._area.width(),
|
|
259
|
+
|
|
260
|
+ // $FlowDisableNextLine: we are sure that this._area is not null
|
|
261
|
+ y: (event.pageY - position.top) / this._area.height()
|
221
|
262
|
});
|
222
|
263
|
});
|
223
|
|
- this.area.mousedown(this._onMouseClickHandler.bind(this,
|
|
264
|
+
|
|
265
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
266
|
+ this._area.mousedown(this._onMouseClickHandler.bind(this,
|
224
|
267
|
EVENT_TYPES.mousedown));
|
225
|
|
- this.area.mouseup(this._onMouseClickHandler.bind(this,
|
|
268
|
+
|
|
269
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
270
|
+ this._area.mouseup(this._onMouseClickHandler.bind(this,
|
226
|
271
|
EVENT_TYPES.mouseup));
|
227
|
|
- this.area.dblclick(
|
|
272
|
+
|
|
273
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
274
|
+ this._area.dblclick(
|
228
|
275
|
this._onMouseClickHandler.bind(this, EVENT_TYPES.mousedblclick));
|
229
|
|
- this.area.contextmenu(() => false);
|
230
|
|
- this.area[0].onmousewheel = event => {
|
231
|
|
- this._sendRemoteControlEvent(this.controlledParticipant, {
|
|
276
|
+
|
|
277
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
278
|
+ this._area.contextmenu(() => false);
|
|
279
|
+
|
|
280
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
281
|
+ this._area[0].onmousewheel = event => {
|
|
282
|
+ this.sendRemoteControlEvent(this._controlledParticipant, {
|
232
|
283
|
type: EVENT_TYPES.mousescroll,
|
233
|
284
|
x: event.deltaX,
|
234
|
285
|
y: event.deltaY
|
|
@@ -243,12 +294,14 @@ export default class Controller extends RemoteControlParticipant {
|
243
|
294
|
* Stops processing the mouse and keyboard events. Removes added listeners.
|
244
|
295
|
* Enables the keyboard shortcuts. Displays dialog to notify the user that
|
245
|
296
|
* remote control session has ended.
|
|
297
|
+ *
|
|
298
|
+ * @returns {void}
|
246
|
299
|
*/
|
247
|
300
|
_stop() {
|
248
|
|
- if(!this.controlledParticipant) {
|
|
301
|
+ if (!this._controlledParticipant) {
|
249
|
302
|
return;
|
250
|
303
|
}
|
251
|
|
- logger.log("Stopping remote control controller.");
|
|
304
|
+ logger.log('Stopping remote control controller.');
|
252
|
305
|
APP.UI.removeListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
253
|
306
|
this._largeVideoChangedListener);
|
254
|
307
|
APP.conference.removeConferenceListener(
|
|
@@ -256,29 +309,28 @@ export default class Controller extends RemoteControlParticipant {
|
256
|
309
|
this._stopListener);
|
257
|
310
|
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
258
|
311
|
this._userLeftListener);
|
259
|
|
- this.controlledParticipant = null;
|
|
312
|
+ this._controlledParticipant = null;
|
260
|
313
|
this.pause();
|
261
|
|
- this.area = null;
|
|
314
|
+ this._area = undefined;
|
262
|
315
|
APP.UI.messageHandler.openMessageDialog(
|
263
|
|
- "dialog.remoteControlTitle",
|
264
|
|
- "dialog.remoteControlStopMessage"
|
|
316
|
+ 'dialog.remoteControlTitle',
|
|
317
|
+ 'dialog.remoteControlStopMessage'
|
265
|
318
|
);
|
266
|
319
|
}
|
267
|
320
|
|
268
|
321
|
/**
|
269
|
|
- * Executes this._stop() mehtod:
|
270
|
|
- * Stops processing the mouse and keyboard events. Removes added listeners.
|
271
|
|
- * Enables the keyboard shortcuts. Displays dialog to notify the user that
|
272
|
|
- * remote control session has ended.
|
|
322
|
+ * Executes this._stop() mehtod which stops processing the mouse and
|
|
323
|
+ * keyboard events, removes added listeners, enables the keyboard shortcuts,
|
|
324
|
+ * displays dialog to notify the user that remote control session has ended.
|
|
325
|
+ * In addition sends stop message to the controlled participant.
|
273
|
326
|
*
|
274
|
|
- * In addition:
|
275
|
|
- * Sends stop message to the controlled participant.
|
|
327
|
+ * @returns {void}
|
276
|
328
|
*/
|
277
|
329
|
stop() {
|
278
|
|
- if(!this.controlledParticipant) {
|
|
330
|
+ if (!this._controlledParticipant) {
|
279
|
331
|
return;
|
280
|
332
|
}
|
281
|
|
- this._sendRemoteControlEvent(this.controlledParticipant, {
|
|
333
|
+ this.sendRemoteControlEvent(this._controlledParticipant, {
|
282
|
334
|
type: EVENT_TYPES.stop
|
283
|
335
|
});
|
284
|
336
|
this._stop();
|
|
@@ -288,88 +340,112 @@ export default class Controller extends RemoteControlParticipant {
|
288
|
340
|
* Pauses the collecting of events and enables the keyboard shortcus. But
|
289
|
341
|
* it doesn't removes any other listeners. Basically the remote control
|
290
|
342
|
* session will be still active after this.pause(), but no events from the
|
291
|
|
- * controller side will be captured and sent.
|
|
343
|
+ * controller side will be captured and sent. You can resume the collecting
|
|
344
|
+ * of the events with this.resume().
|
292
|
345
|
*
|
293
|
|
- * You can resume the collecting of the events with this.resume().
|
|
346
|
+ * @returns {void}
|
294
|
347
|
*/
|
295
|
348
|
pause() {
|
296
|
|
- if(!this.controlledParticipant) {
|
|
349
|
+ if (!this._controlledParticipant) {
|
297
|
350
|
return;
|
298
|
351
|
}
|
299
|
|
- logger.log("Pausing remote control controller.");
|
300
|
|
- this.isCollectingEvents = false;
|
|
352
|
+ logger.log('Pausing remote control controller.');
|
|
353
|
+ this._isCollectingEvents = false;
|
301
|
354
|
APP.keyboardshortcut.enable(true);
|
302
|
|
- this.area.off( "mousemove" );
|
303
|
|
- this.area.off( "mousedown" );
|
304
|
|
- this.area.off( "mouseup" );
|
305
|
|
- this.area.off( "contextmenu" );
|
306
|
|
- this.area.off( "dblclick" );
|
307
|
|
- $(window).off( "keydown");
|
308
|
|
- $(window).off( "keyup");
|
309
|
|
- this.area[0].onmousewheel = undefined;
|
|
355
|
+
|
|
356
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
357
|
+ this._area.off('mousemove');
|
|
358
|
+
|
|
359
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
360
|
+ this._area.off('mousedown');
|
|
361
|
+
|
|
362
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
363
|
+ this._area.off('mouseup');
|
|
364
|
+
|
|
365
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
366
|
+ this._area.off('contextmenu');
|
|
367
|
+
|
|
368
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
369
|
+ this._area.off('dblclick');
|
|
370
|
+
|
|
371
|
+ $(window).off('keydown');
|
|
372
|
+ $(window).off('keyup');
|
|
373
|
+
|
|
374
|
+ // $FlowDisableNextLine: we are sure that this._area is not null.
|
|
375
|
+ this._area[0].onmousewheel = undefined;
|
310
|
376
|
}
|
311
|
377
|
|
312
|
378
|
/**
|
313
|
379
|
* Handler for mouse click events.
|
314
|
|
- * @param {String} type the type of event ("mousedown"/"mouseup")
|
315
|
|
- * @param {Event} event the mouse event.
|
|
380
|
+ *
|
|
381
|
+ * @param {string} type - The type of event ("mousedown"/"mouseup").
|
|
382
|
+ * @param {Event} event - The mouse event.
|
|
383
|
+ * @returns {void}
|
316
|
384
|
*/
|
317
|
|
- _onMouseClickHandler(type, event) {
|
318
|
|
- this._sendRemoteControlEvent(this.controlledParticipant, {
|
319
|
|
- type: type,
|
|
385
|
+ _onMouseClickHandler(type: string, event: Object) {
|
|
386
|
+ this.sendRemoteControlEvent(this._controlledParticipant, {
|
|
387
|
+ type,
|
320
|
388
|
button: event.which
|
321
|
389
|
});
|
322
|
390
|
}
|
323
|
391
|
|
324
|
392
|
/**
|
325
|
393
|
* Returns true if the remote control session is started.
|
|
394
|
+ *
|
326
|
395
|
* @returns {boolean}
|
327
|
396
|
*/
|
328
|
397
|
isStarted() {
|
329
|
|
- return this.controlledParticipant !== null;
|
|
398
|
+ return this._controlledParticipant !== null;
|
330
|
399
|
}
|
331
|
400
|
|
332
|
401
|
/**
|
333
|
|
- * Returns the id of the requested participant
|
334
|
|
- * @returns {string} this.requestedParticipant.
|
|
402
|
+ * Returns the id of the requested participant.
|
|
403
|
+ *
|
|
404
|
+ * @returns {string} The id of the requested participant.
|
335
|
405
|
* NOTE: This id should be the result of JitsiParticipant.getId() call.
|
336
|
406
|
*/
|
337
|
407
|
getRequestedParticipant() {
|
338
|
|
- return this.requestedParticipant;
|
|
408
|
+ return this._requestedParticipant;
|
339
|
409
|
}
|
340
|
410
|
|
341
|
411
|
/**
|
342
|
412
|
* Handler for key press events.
|
343
|
|
- * @param {String} type the type of event ("keydown"/"keyup")
|
344
|
|
- * @param {Event} event the key event.
|
|
413
|
+ *
|
|
414
|
+ * @param {string} type - The type of event ("keydown"/"keyup").
|
|
415
|
+ * @param {Event} event - The key event.
|
|
416
|
+ * @returns {void}
|
345
|
417
|
*/
|
346
|
|
- _onKeyPessHandler(type, event) {
|
347
|
|
- this._sendRemoteControlEvent(this.controlledParticipant, {
|
348
|
|
- type: type,
|
|
418
|
+ _onKeyPessHandler(type: string, event: Object) {
|
|
419
|
+ this.sendRemoteControlEvent(this._controlledParticipant, {
|
|
420
|
+ type,
|
349
|
421
|
key: getKey(event),
|
350
|
|
- modifiers: getModifiers(event),
|
|
422
|
+ modifiers: getModifiers(event)
|
351
|
423
|
});
|
352
|
424
|
}
|
353
|
425
|
|
354
|
426
|
/**
|
355
|
427
|
* Calls the stop method if the other side have left.
|
356
|
|
- * @param {string} id - the user id for the participant that have left
|
|
428
|
+ *
|
|
429
|
+ * @param {string} id - The user id for the participant that have left.
|
|
430
|
+ * @returns {void}
|
357
|
431
|
*/
|
358
|
|
- _onUserLeft(id) {
|
359
|
|
- if(this.controlledParticipant === id) {
|
|
432
|
+ _onUserLeft(id: string) {
|
|
433
|
+ if (this._controlledParticipant === id) {
|
360
|
434
|
this._stop();
|
361
|
435
|
}
|
362
|
436
|
}
|
363
|
437
|
|
364
|
438
|
/**
|
365
|
439
|
* Handles changes of the participant displayed on the large video.
|
366
|
|
- * @param {string} id - the user id for the participant that is displayed.
|
|
440
|
+ *
|
|
441
|
+ * @param {string} id - The user id for the participant that is displayed.
|
|
442
|
+ * @returns {void}
|
367
|
443
|
*/
|
368
|
|
- _onLargeVideoIdChanged(id) {
|
369
|
|
- if (!this.controlledParticipant) {
|
|
444
|
+ _onLargeVideoIdChanged(id: string) {
|
|
445
|
+ if (!this._controlledParticipant) {
|
370
|
446
|
return;
|
371
|
447
|
}
|
372
|
|
- if(this.controlledParticipant == id) {
|
|
448
|
+ if (this._controlledParticipant === id) {
|
373
|
449
|
this.resume();
|
374
|
450
|
} else {
|
375
|
451
|
this.pause();
|