|
@@ -6,10 +6,10 @@ import {
|
6
|
6
|
EVENT_TYPES,
|
7
|
7
|
PERMISSIONS_ACTIONS,
|
8
|
8
|
REMOTE_CONTROL_EVENT_TYPE
|
9
|
|
-} from "../../service/remotecontrol/Constants";
|
|
9
|
+} from '../../service/remotecontrol/Constants';
|
10
|
10
|
import { getJitsiMeetTransport } from '../transport';
|
11
|
11
|
|
12
|
|
-import RemoteControlParticipant from "./RemoteControlParticipant";
|
|
12
|
+import RemoteControlParticipant from './RemoteControlParticipant';
|
13
|
13
|
|
14
|
14
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
15
|
15
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
@@ -41,8 +41,8 @@ export default class Receiver extends RemoteControlParticipant {
|
41
|
41
|
this._hangupListener = this._onHangup.bind(this);
|
42
|
42
|
// We expect here that even if we receive the supported event earlier
|
43
|
43
|
// it will be cached and we'll receive it.
|
44
|
|
- transport.on('event', ({ event, name }) => {
|
45
|
|
- if(name === REMOTE_CONTROL_EVENT_TYPE) {
|
|
44
|
+ transport.on('event', event => {
|
|
45
|
+ if (event.name === REMOTE_CONTROL_EVENT_TYPE) {
|
46
|
46
|
this._onRemoteControlAPIEvent(event);
|
47
|
47
|
|
48
|
48
|
return true;
|
|
@@ -100,9 +100,7 @@ export default class Receiver extends RemoteControlParticipant {
|
100
|
100
|
this._userLeftListener);
|
101
|
101
|
transport.sendEvent({
|
102
|
102
|
name: REMOTE_CONTROL_EVENT_TYPE,
|
103
|
|
- event: {
|
104
|
|
- type: EVENT_TYPES.stop
|
105
|
|
- }
|
|
103
|
+ type: EVENT_TYPES.stop
|
106
|
104
|
});
|
107
|
105
|
if(!dontShowDialog) {
|
108
|
106
|
APP.UI.messageHandler.openMessageDialog(
|
|
@@ -131,16 +129,21 @@ export default class Receiver extends RemoteControlParticipant {
|
131
|
129
|
* module.
|
132
|
130
|
* @param {JitsiParticipant} participant the controller participant
|
133
|
131
|
* @param {Object} event EndpointMessage event from the data channels.
|
134
|
|
- * @property {string} type property. The function process only events of
|
135
|
|
- * type REMOTE_CONTROL_EVENT_TYPE
|
|
132
|
+ * @property {string} type property. The function process only events with
|
|
133
|
+ * name REMOTE_CONTROL_EVENT_TYPE
|
136
|
134
|
* @property {RemoteControlEvent} event - the remote control event.
|
137
|
135
|
*/
|
138
|
136
|
_onRemoteControlEvent(participant, event) {
|
139
|
|
- if(this.enabled && event.type === REMOTE_CONTROL_EVENT_TYPE) {
|
140
|
|
- const remoteControlEvent = event.event;
|
141
|
|
- if(this.controller === null
|
142
|
|
- && remoteControlEvent.type === EVENT_TYPES.permissions
|
143
|
|
- && remoteControlEvent.action === PERMISSIONS_ACTIONS.request) {
|
|
137
|
+ if (event.name !== REMOTE_CONTROL_EVENT_TYPE) {
|
|
138
|
+ return;
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ const remoteControlEvent = Object.assign({}, event);
|
|
142
|
+
|
|
143
|
+ if (this.enabled) {
|
|
144
|
+ if (this.controller === null
|
|
145
|
+ && event.type === EVENT_TYPES.permissions
|
|
146
|
+ && event.action === PERMISSIONS_ACTIONS.request) {
|
144
|
147
|
// FIXME: Maybe use transport.sendRequest in this case???
|
145
|
148
|
remoteControlEvent.userId = participant.getId();
|
146
|
149
|
remoteControlEvent.userJID = participant.getJid();
|
|
@@ -148,17 +151,14 @@ export default class Receiver extends RemoteControlParticipant {
|
148
|
151
|
|| interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
149
|
152
|
remoteControlEvent.screenSharing
|
150
|
153
|
= APP.conference.isSharingScreen;
|
151
|
|
- } else if(this.controller !== participant.getId()) {
|
|
154
|
+ } else if (this.controller !== participant.getId()) {
|
152
|
155
|
return;
|
153
|
|
- } else if(remoteControlEvent.type === EVENT_TYPES.stop) {
|
|
156
|
+ } else if (event.type === EVENT_TYPES.stop) {
|
154
|
157
|
this._stop();
|
155
|
158
|
return;
|
156
|
159
|
}
|
157
|
|
- transport.sendEvent({
|
158
|
|
- name: REMOTE_CONTROL_EVENT_TYPE,
|
159
|
|
- event: remoteControlEvent
|
160
|
|
- });
|
161
|
|
- } else if(event.type === REMOTE_CONTROL_EVENT_TYPE) {
|
|
160
|
+ transport.sendEvent(remoteControlEvent);
|
|
161
|
+ } else {
|
162
|
162
|
logger.log("Remote control event is ignored because remote "
|
163
|
163
|
+ "control is disabled", event);
|
164
|
164
|
}
|
|
@@ -171,7 +171,7 @@ export default class Receiver extends RemoteControlParticipant {
|
171
|
171
|
* @param {PERMISSIONS_ACTIONS} action the action related to the event.
|
172
|
172
|
*/
|
173
|
173
|
_onRemoteControlPermissionsEvent(userId, action) {
|
174
|
|
- if(action === PERMISSIONS_ACTIONS.grant) {
|
|
174
|
+ if (action === PERMISSIONS_ACTIONS.grant) {
|
175
|
175
|
APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
|
176
|
176
|
this._userLeftListener);
|
177
|
177
|
this.controller = userId;
|
|
@@ -227,7 +227,7 @@ export default class Receiver extends RemoteControlParticipant {
|
227
|
227
|
*/
|
228
|
228
|
_onRemoteControlSupported() {
|
229
|
229
|
logger.log("Remote Control supported.");
|
230
|
|
- if(!config.disableRemoteControl) {
|
|
230
|
+ if (!config.disableRemoteControl) {
|
231
|
231
|
this._enable(true);
|
232
|
232
|
} else {
|
233
|
233
|
logger.log("Remote Control disabled.");
|