Kaynağa Gözat

ref(remotecontrol): Changing the format of the messages

j8
hristoterezov 8 yıl önce
ebeveyn
işleme
b297aa3f3a

+ 1
- 0
.jshintignore Dosyayı Görüntüle

9
 # supersedes JSHint.
9
 # supersedes JSHint.
10
 flow-typed/
10
 flow-typed/
11
 modules/API/
11
 modules/API/
12
+modules/remotecontrol/RemoteControlParticipant.js
12
 modules/transport/
13
 modules/transport/
13
 react/
14
 react/
14
 
15
 

+ 8
- 9
modules/remotecontrol/Controller.js Dosyayı Görüntüle

132
      * @param {RemoteControlEvent} event the remote control event.
132
      * @param {RemoteControlEvent} event the remote control event.
133
      */
133
      */
134
     _handleReply(participant, event) {
134
     _handleReply(participant, event) {
135
-        const remoteControlEvent = event.event;
136
         const userId = participant.getId();
135
         const userId = participant.getId();
137
-        if(this.enabled && event.type === REMOTE_CONTROL_EVENT_TYPE
138
-            && remoteControlEvent.type === EVENT_TYPES.permissions
136
+        if(this.enabled && event.name === REMOTE_CONTROL_EVENT_TYPE
137
+            && event.type === EVENT_TYPES.permissions
139
             && userId === this.requestedParticipant) {
138
             && userId === this.requestedParticipant) {
140
-            if(remoteControlEvent.action !== PERMISSIONS_ACTIONS.grant) {
139
+            if(event.action !== PERMISSIONS_ACTIONS.grant) {
141
                 this.area = null;
140
                 this.area = null;
142
             }
141
             }
143
-            switch(remoteControlEvent.action) {
142
+            switch(event.action) {
144
                 case PERMISSIONS_ACTIONS.grant: {
143
                 case PERMISSIONS_ACTIONS.grant: {
145
                     this.controlledParticipant = userId;
144
                     this.controlledParticipant = userId;
146
                     logger.log("Remote control permissions granted to: "
145
                     logger.log("Remote control permissions granted to: "
166
      * @param {JitsiParticipant} participant the participant that has sent the
165
      * @param {JitsiParticipant} participant the participant that has sent the
167
      * event
166
      * event
168
      * @param {Object} event EndpointMessage event from the data channels.
167
      * @param {Object} event EndpointMessage event from the data channels.
169
-     * @property {string} type property. The function process only events of
170
-     * type REMOTE_CONTROL_EVENT_TYPE
168
+     * @property {string} type property. The function process only events with
169
+     * name REMOTE_CONTROL_EVENT_TYPE
171
      * @property {RemoteControlEvent} event - the remote control event.
170
      * @property {RemoteControlEvent} event - the remote control event.
172
      */
171
      */
173
     _handleRemoteControlStoppedEvent(participant, event) {
172
     _handleRemoteControlStoppedEvent(participant, event) {
174
-        if(this.enabled && event.type === REMOTE_CONTROL_EVENT_TYPE
175
-            && event.event.type === EVENT_TYPES.stop
173
+        if(this.enabled && event.name === REMOTE_CONTROL_EVENT_TYPE
174
+            && event.type === EVENT_TYPES.stop
176
             && participant.getId() === this.controlledParticipant) {
175
             && participant.getId() === this.controlledParticipant) {
177
             this._stop();
176
             this._stop();
178
         }
177
         }

+ 23
- 23
modules/remotecontrol/Receiver.js Dosyayı Görüntüle

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

+ 4
- 2
modules/remotecontrol/RemoteControlParticipant.js Dosyayı Görüntüle

31
             return;
31
             return;
32
         }
32
         }
33
         try{
33
         try{
34
-            APP.conference.sendEndpointMessage(to,
35
-                {type: REMOTE_CONTROL_EVENT_TYPE, event});
34
+            APP.conference.sendEndpointMessage(to, {
35
+                name: REMOTE_CONTROL_EVENT_TYPE,
36
+                ...event
37
+            });
36
         } catch (e) {
38
         } catch (e) {
37
             logger.error("Failed to send EndpointMessage via the datachannels",
39
             logger.error("Failed to send EndpointMessage via the datachannels",
38
                 e);
40
                 e);

+ 1
- 1
modules/transport/Transport.js Dosyayı Görüntüle

232
         const id = this._requestID;
232
         const id = this._requestID;
233
 
233
 
234
         return new Promise((resolve, reject) => {
234
         return new Promise((resolve, reject) => {
235
-            this._responseHandlers.set(this._requestID, ({ error, result }) => {
235
+            this._responseHandlers.set(id, ({ error, result }) => {
236
                 if (result) {
236
                 if (result) {
237
                     resolve(result);
237
                     resolve(result);
238
                 } else if (error) {
238
                 } else if (error) {

Loading…
İptal
Kaydet