|
@@ -3,6 +3,7 @@ import * as KeyCodes from "../keycode/keycode";
|
3
|
3
|
import {EVENT_TYPES, REMOTE_CONTROL_EVENT_TYPE, PERMISSIONS_ACTIONS}
|
4
|
4
|
from "../../service/remotecontrol/Constants";
|
5
|
5
|
import RemoteControlParticipant from "./RemoteControlParticipant";
|
|
6
|
+import UIEvents from "../../service/UI/UIEvents";
|
6
|
7
|
|
7
|
8
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
8
|
9
|
|
|
@@ -53,10 +54,13 @@ export default class Controller extends RemoteControlParticipant {
|
53
|
54
|
*/
|
54
|
55
|
constructor() {
|
55
|
56
|
super();
|
|
57
|
+ this.isCollectingEvents = false;
|
56
|
58
|
this.controlledParticipant = null;
|
57
|
59
|
this.requestedParticipant = null;
|
58
|
60
|
this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
|
59
|
61
|
this._userLeftListener = this._onUserLeft.bind(this);
|
|
62
|
+ this._largeVideoChangedListener
|
|
63
|
+ = this._onLargeVideoIdChanged.bind(this);
|
60
|
64
|
}
|
61
|
65
|
|
62
|
66
|
/**
|
|
@@ -162,17 +166,36 @@ export default class Controller extends RemoteControlParticipant {
|
162
|
166
|
}
|
163
|
167
|
|
164
|
168
|
/**
|
165
|
|
- * Starts processing the mouse and keyboard events.
|
|
169
|
+ * Starts processing the mouse and keyboard events. Sets conference
|
|
170
|
+ * listeners. Disables keyboard events.
|
166
|
171
|
*/
|
167
|
172
|
_start() {
|
168
|
|
- if(!this.enabled)
|
|
173
|
+ if(!this.enabled) {
|
169
|
174
|
return;
|
170
|
|
- APP.keyboardshortcut.enable(false);
|
|
175
|
+ }
|
|
176
|
+ APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
|
177
|
+ this._largeVideoChangedListener);
|
171
|
178
|
APP.conference.addConferenceListener(
|
172
|
179
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
173
|
180
|
this._stopListener);
|
174
|
181
|
APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
|
175
|
182
|
this._userLeftListener);
|
|
183
|
+ this.resume();
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ /**
|
|
187
|
+ * Disables the keyboatd shortcuts. Starts collecting remote control
|
|
188
|
+ * events.
|
|
189
|
+ *
|
|
190
|
+ * It can be used to resume an active remote control session wchich was
|
|
191
|
+ * paused with this.pause().
|
|
192
|
+ */
|
|
193
|
+ resume() {
|
|
194
|
+ if(!this.enabled || this.isCollectingEvents) {
|
|
195
|
+ return;
|
|
196
|
+ }
|
|
197
|
+ this.isCollectingEvents = true;
|
|
198
|
+ APP.keyboardshortcut.enable(false);
|
176
|
199
|
this.area = $("#largeVideoWrapper");
|
177
|
200
|
this.area.mousemove(event => {
|
178
|
201
|
const position = this.area.position();
|
|
@@ -203,26 +226,22 @@ export default class Controller extends RemoteControlParticipant {
|
203
|
226
|
|
204
|
227
|
/**
|
205
|
228
|
* Stops processing the mouse and keyboard events. Removes added listeners.
|
|
229
|
+ * Enables the keyboard shortcuts. Displays dialog to notify the user that
|
|
230
|
+ * remote control session has ended.
|
206
|
231
|
*/
|
207
|
232
|
_stop() {
|
208
|
233
|
if(!this.controlledParticipant) {
|
209
|
234
|
return;
|
210
|
235
|
}
|
211
|
|
- APP.keyboardshortcut.enable(true);
|
|
236
|
+ APP.UI.removeListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
|
|
237
|
+ this._largeVideoChangedListener);
|
212
|
238
|
APP.conference.removeConferenceListener(
|
213
|
239
|
ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
214
|
240
|
this._stopListener);
|
215
|
241
|
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
216
|
242
|
this._userLeftListener);
|
217
|
243
|
this.controlledParticipant = null;
|
218
|
|
- this.area.off( "mousemove" );
|
219
|
|
- this.area.off( "mousedown" );
|
220
|
|
- this.area.off( "mouseup" );
|
221
|
|
- this.area.off( "contextmenu" );
|
222
|
|
- this.area.off( "dblclick" );
|
223
|
|
- $(window).off( "keydown");
|
224
|
|
- $(window).off( "keyup");
|
225
|
|
- this.area[0].onmousewheel = undefined;
|
|
244
|
+ this.pause();
|
226
|
245
|
APP.UI.messageHandler.openMessageDialog(
|
227
|
246
|
"dialog.remoteControlTitle",
|
228
|
247
|
"dialog.remoteControlStopMessage"
|
|
@@ -230,7 +249,13 @@ export default class Controller extends RemoteControlParticipant {
|
230
|
249
|
}
|
231
|
250
|
|
232
|
251
|
/**
|
233
|
|
- * Calls this._stop() and sends stop message to the controlled participant.
|
|
252
|
+ * Executes this._stop() mehtod:
|
|
253
|
+ * Stops processing the mouse and keyboard events. Removes added listeners.
|
|
254
|
+ * Enables the keyboard shortcuts. Displays dialog to notify the user that
|
|
255
|
+ * remote control session has ended.
|
|
256
|
+ *
|
|
257
|
+ * In addition:
|
|
258
|
+ * Sends stop message to the controlled participant.
|
234
|
259
|
*/
|
235
|
260
|
stop() {
|
236
|
261
|
if(!this.controlledParticipant) {
|
|
@@ -242,6 +267,30 @@ export default class Controller extends RemoteControlParticipant {
|
242
|
267
|
this._stop();
|
243
|
268
|
}
|
244
|
269
|
|
|
270
|
+ /**
|
|
271
|
+ * Pauses the collecting of events and enables the keyboard shortcus. But
|
|
272
|
+ * it doesn't removes any other listeners. Basically the remote control
|
|
273
|
+ * session will be still active after this.pause(), but no events from the
|
|
274
|
+ * controller side will be captured and sent.
|
|
275
|
+ *
|
|
276
|
+ * You can resume the collecting of the events with this.resume().
|
|
277
|
+ */
|
|
278
|
+ pause() {
|
|
279
|
+ if(!this.controlledParticipant) {
|
|
280
|
+ return;
|
|
281
|
+ }
|
|
282
|
+ this.isCollectingEvents = false;
|
|
283
|
+ APP.keyboardshortcut.enable(true);
|
|
284
|
+ this.area.off( "mousemove" );
|
|
285
|
+ this.area.off( "mousedown" );
|
|
286
|
+ this.area.off( "mouseup" );
|
|
287
|
+ this.area.off( "contextmenu" );
|
|
288
|
+ this.area.off( "dblclick" );
|
|
289
|
+ $(window).off( "keydown");
|
|
290
|
+ $(window).off( "keyup");
|
|
291
|
+ this.area[0].onmousewheel = undefined;
|
|
292
|
+ }
|
|
293
|
+
|
245
|
294
|
/**
|
246
|
295
|
* Handler for mouse click events.
|
247
|
296
|
* @param {String} type the type of event ("mousedown"/"mouseup")
|
|
@@ -292,4 +341,19 @@ export default class Controller extends RemoteControlParticipant {
|
292
|
341
|
this._stop();
|
293
|
342
|
}
|
294
|
343
|
}
|
|
344
|
+
|
|
345
|
+ /**
|
|
346
|
+ * Handles changes of the participant displayed on the large video.
|
|
347
|
+ * @param {string} id - the user id for the participant that is displayed.
|
|
348
|
+ */
|
|
349
|
+ _onLargeVideoIdChanged(id) {
|
|
350
|
+ if (!this.controlledParticipant) {
|
|
351
|
+ return;
|
|
352
|
+ }
|
|
353
|
+ if(this.controlledParticipant == id) {
|
|
354
|
+ this.resume();
|
|
355
|
+ } else {
|
|
356
|
+ this.pause();
|
|
357
|
+ }
|
|
358
|
+ }
|
295
|
359
|
}
|