|
@@ -1,10 +1,16 @@
|
1
|
|
-/* global APP, JitsiMeetJS, interfaceConfig */
|
2
|
|
-const logger = require("jitsi-meet-logger").getLogger(__filename);
|
3
|
|
-import {DISCO_REMOTE_CONTROL_FEATURE, REMOTE_CONTROL_EVENT_TYPE, EVENT_TYPES,
|
4
|
|
- PERMISSIONS_ACTIONS} from "../../service/remotecontrol/Constants";
|
5
|
|
-import RemoteControlParticipant from "./RemoteControlParticipant";
|
|
1
|
+/* global APP, JitsiMeetJS, interfaceConfig, config */
|
6
|
2
|
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
|
3
|
+import {
|
|
4
|
+ DISCO_REMOTE_CONTROL_FEATURE,
|
|
5
|
+ EVENT_TYPES,
|
|
6
|
+ PERMISSIONS_ACTIONS,
|
|
7
|
+ REMOTE_CONTROL_EVENT_TYPE
|
|
8
|
+} from "../../service/remotecontrol/Constants";
|
|
9
|
+import { transport } from '../transport';
|
|
10
|
+
|
|
11
|
+import RemoteControlParticipant from "./RemoteControlParticipant";
|
7
|
12
|
|
|
13
|
+const logger = require("jitsi-meet-logger").getLogger(__filename);
|
8
|
14
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
9
|
15
|
|
10
|
16
|
/**
|
|
@@ -25,13 +31,24 @@ export default class Receiver extends RemoteControlParticipant {
|
25
|
31
|
= this._onRemoteControlEvent.bind(this);
|
26
|
32
|
this._userLeftListener = this._onUserLeft.bind(this);
|
27
|
33
|
this._hangupListener = this._onHangup.bind(this);
|
|
34
|
+ // We expect here that even if we receive the supported event earlier
|
|
35
|
+ // it will be cached and we'll receive it.
|
|
36
|
+ transport.on('event', data => {
|
|
37
|
+ if(data.name === REMOTE_CONTROL_EVENT_TYPE) {
|
|
38
|
+ this._onRemoteControlAPIEvent(data.event);
|
|
39
|
+
|
|
40
|
+ return true;
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ return false;
|
|
44
|
+ });
|
28
|
45
|
}
|
29
|
46
|
|
30
|
47
|
/**
|
31
|
48
|
* Enables / Disables the remote control
|
32
|
49
|
* @param {boolean} enabled the new state.
|
33
|
50
|
*/
|
34
|
|
- enable(enabled) {
|
|
51
|
+ _enable(enabled) {
|
35
|
52
|
if(this.enabled === enabled) {
|
36
|
53
|
return;
|
37
|
54
|
}
|
|
@@ -73,8 +90,11 @@ export default class Receiver extends RemoteControlParticipant {
|
73
|
90
|
this.controller = null;
|
74
|
91
|
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
75
|
92
|
this._userLeftListener);
|
76
|
|
- APP.API.sendRemoteControlEvent({
|
77
|
|
- type: EVENT_TYPES.stop
|
|
93
|
+ transport.sendEvent({
|
|
94
|
+ name: REMOTE_CONTROL_EVENT_TYPE,
|
|
95
|
+ event: {
|
|
96
|
+ type: EVENT_TYPES.stop
|
|
97
|
+ }
|
78
|
98
|
});
|
79
|
99
|
if(!dontShowDialog) {
|
80
|
100
|
APP.UI.messageHandler.openMessageDialog(
|
|
@@ -113,6 +133,7 @@ export default class Receiver extends RemoteControlParticipant {
|
113
|
133
|
if(this.controller === null
|
114
|
134
|
&& remoteControlEvent.type === EVENT_TYPES.permissions
|
115
|
135
|
&& remoteControlEvent.action === PERMISSIONS_ACTIONS.request) {
|
|
136
|
+ // FIXME: Maybe use transport.sendRequest in this case???
|
116
|
137
|
remoteControlEvent.userId = participant.getId();
|
117
|
138
|
remoteControlEvent.userJID = participant.getJid();
|
118
|
139
|
remoteControlEvent.displayName = participant.getDisplayName()
|
|
@@ -125,7 +146,10 @@ export default class Receiver extends RemoteControlParticipant {
|
125
|
146
|
this._stop();
|
126
|
147
|
return;
|
127
|
148
|
}
|
128
|
|
- APP.API.sendRemoteControlEvent(remoteControlEvent);
|
|
149
|
+ transport.sendEvent({
|
|
150
|
+ name: REMOTE_CONTROL_EVENT_TYPE,
|
|
151
|
+ event: remoteControlEvent
|
|
152
|
+ });
|
129
|
153
|
} else if(event.type === REMOTE_CONTROL_EVENT_TYPE) {
|
130
|
154
|
logger.log("Remote control event is ignored because remote "
|
131
|
155
|
+ "control is disabled", event);
|
|
@@ -133,7 +157,7 @@ export default class Receiver extends RemoteControlParticipant {
|
133
|
157
|
}
|
134
|
158
|
|
135
|
159
|
/**
|
136
|
|
- * Handles remote control permission events received from the API module.
|
|
160
|
+ * Handles remote control permission events.
|
137
|
161
|
* @param {String} userId the user id of the participant related to the
|
138
|
162
|
* event.
|
139
|
163
|
* @param {PERMISSIONS_ACTIONS} action the action related to the event.
|
|
@@ -173,6 +197,36 @@ export default class Receiver extends RemoteControlParticipant {
|
173
|
197
|
});
|
174
|
198
|
}
|
175
|
199
|
|
|
200
|
+ /**
|
|
201
|
+ * Handles remote control events from the external app. Currently only
|
|
202
|
+ * events with type = EVENT_TYPES.supported or EVENT_TYPES.permissions
|
|
203
|
+ * @param {RemoteControlEvent} event the remote control event.
|
|
204
|
+ */
|
|
205
|
+ _onRemoteControlAPIEvent(event) {
|
|
206
|
+ switch(event.type) {
|
|
207
|
+ case EVENT_TYPES.supported:
|
|
208
|
+ this._onRemoteControlSupported();
|
|
209
|
+ break;
|
|
210
|
+ case EVENT_TYPES.permissions:
|
|
211
|
+ this._onRemoteControlPermissionsEvent(
|
|
212
|
+ event.userId, event.action);
|
|
213
|
+ break;
|
|
214
|
+ }
|
|
215
|
+ }
|
|
216
|
+
|
|
217
|
+ /**
|
|
218
|
+ * Handles events for support for executing remote control events into
|
|
219
|
+ * the wrapper application.
|
|
220
|
+ */
|
|
221
|
+ _onRemoteControlSupported() {
|
|
222
|
+ logger.log("Remote Control supported.");
|
|
223
|
+ if(!config.disableRemoteControl) {
|
|
224
|
+ this._enable(true);
|
|
225
|
+ } else {
|
|
226
|
+ logger.log("Remote Control disabled.");
|
|
227
|
+ }
|
|
228
|
+ }
|
|
229
|
+
|
176
|
230
|
/**
|
177
|
231
|
* Calls the stop method if the other side have left.
|
178
|
232
|
* @param {string} id - the user id for the participant that have left
|
|
@@ -187,6 +241,6 @@ export default class Receiver extends RemoteControlParticipant {
|
187
|
241
|
* Handles hangup events. Disables the receiver.
|
188
|
242
|
*/
|
189
|
243
|
_onHangup() {
|
190
|
|
- this.enable(false);
|
|
244
|
+ this._enable(false);
|
191
|
245
|
}
|
192
|
246
|
}
|