浏览代码

ref(conference.js): remove global promise

Get rid of global APP.conference.screenSharingPromise.
master
paweldomas 8 年前
父节点
当前提交
e7a4318e8c
共有 2 个文件被更改,包括 28 次插入21 次删除
  1. 13
    7
      conference.js
  2. 15
    14
      modules/remotecontrol/Receiver.js

+ 13
- 7
conference.js 查看文件

1109
     },
1109
     },
1110
 
1110
 
1111
     videoSwitchInProgress: false,
1111
     videoSwitchInProgress: false,
1112
+
1113
+    /**
1114
+     * Toggles between screensharing and camera video.
1115
+     * @param {boolean} [shareScreen]
1116
+     * @return {Promise.<T>}
1117
+     */
1112
     toggleScreenSharing(shareScreen = !this.isSharingScreen) {
1118
     toggleScreenSharing(shareScreen = !this.isSharingScreen) {
1113
         if (this.videoSwitchInProgress) {
1119
         if (this.videoSwitchInProgress) {
1114
-            logger.warn("Switch in progress.");
1115
-            return;
1120
+            return Promise.reject('Switch in progress.');
1116
         }
1121
         }
1117
         if (!this.isDesktopSharingEnabled) {
1122
         if (!this.isDesktopSharingEnabled) {
1118
-            logger.warn("Cannot toggle screen sharing: not supported.");
1119
-            return;
1123
+            return Promise.reject(
1124
+                'Cannot toggle screen sharing: not supported.');
1120
         }
1125
         }
1121
 
1126
 
1122
         if (this.isAudioOnly()) {
1127
         if (this.isAudioOnly()) {
1123
             this._displayAudioOnlyTooltip('screenShare');
1128
             this._displayAudioOnlyTooltip('screenShare');
1124
-            return;
1129
+
1130
+            return Promise.reject('No screensharing in audio only mode');
1125
         }
1131
         }
1126
 
1132
 
1127
         this.videoSwitchInProgress = true;
1133
         this.videoSwitchInProgress = true;
1128
         let externalInstallation = false;
1134
         let externalInstallation = false;
1129
 
1135
 
1130
         if (shareScreen) {
1136
         if (shareScreen) {
1131
-            this.screenSharingPromise = createLocalTracks({
1137
+            return createLocalTracks({
1132
                 devices: ['desktop'],
1138
                 devices: ['desktop'],
1133
                 desktopSharingExtensionExternalInstallation: {
1139
                 desktopSharingExtensionExternalInstallation: {
1134
                     interval: 500,
1140
                     interval: 500,
1218
             });
1224
             });
1219
         } else {
1225
         } else {
1220
             APP.remoteControl.receiver.stop();
1226
             APP.remoteControl.receiver.stop();
1221
-            this.screenSharingPromise = createLocalTracks(
1227
+            return createLocalTracks(
1222
                 { devices: ['video'] })
1228
                 { devices: ['video'] })
1223
             .then(
1229
             .then(
1224
                 ([stream]) => this.useVideoStream(stream)
1230
                 ([stream]) => this.useVideoStream(stream)

+ 15
- 14
modules/remotecontrol/Receiver.js 查看文件

261
                 action: PERMISSIONS_ACTIONS.grant
261
                 action: PERMISSIONS_ACTIONS.grant
262
             });
262
             });
263
         } else {
263
         } else {
264
-            APP.conference.toggleScreenSharing();
265
-            APP.conference.screenSharingPromise.then(() => {
266
-                if (APP.conference.isSharingScreen) {
267
-                    this.sendRemoteControlEvent(userId, {
268
-                        type: EVENT_TYPES.permissions,
269
-                        action: PERMISSIONS_ACTIONS.grant
270
-                    });
271
-                } else {
264
+            APP.conference.toggleScreenSharing()
265
+                .then(() => {
266
+                    if (APP.conference.isSharingScreen) {
267
+                        this.sendRemoteControlEvent(userId, {
268
+                            type: EVENT_TYPES.permissions,
269
+                            action: PERMISSIONS_ACTIONS.grant
270
+                        });
271
+                    } else {
272
+                        this.sendRemoteControlEvent(userId, {
273
+                            type: EVENT_TYPES.permissions,
274
+                            action: PERMISSIONS_ACTIONS.error
275
+                        });
276
+                    }
277
+                })
278
+                .catch(() => {
272
                     this.sendRemoteControlEvent(userId, {
279
                     this.sendRemoteControlEvent(userId, {
273
                         type: EVENT_TYPES.permissions,
280
                         type: EVENT_TYPES.permissions,
274
                         action: PERMISSIONS_ACTIONS.error
281
                         action: PERMISSIONS_ACTIONS.error
275
                     });
282
                     });
276
-                }
277
-            }).catch(() => {
278
-                this.sendRemoteControlEvent(userId, {
279
-                    type: EVENT_TYPES.permissions,
280
-                    action: PERMISSIONS_ACTIONS.error
281
                 });
283
                 });
282
-            });
283
         }
284
         }
284
     }
285
     }
285
 
286
 

正在加载...
取消
保存