ソースを参照

fix(frame_api): toggle SS race condition

If toggle SS is executed too early and lib-jitsi-meet is not yet
initialized toggle SS will fail. Now we are storing the whether
SS is on or off and when lib-jitsi-meet is ready we are starting
SS if needed.
j8
hristoterezov 8年前
コミット
e7a3ee477d
3個のファイルの変更56行の追加4行の削除
  1. 7
    0
      ConferenceEvents.js
  2. 3
    0
      conference.js
  3. 46
    4
      modules/API/API.js

+ 7
- 0
ConferenceEvents.js ファイルの表示

@@ -2,3 +2,10 @@
2 2
  * Notifies interested parties that hangup procedure will start.
3 3
  */
4 4
 export const BEFORE_HANGUP = "conference.before_hangup";
5
+
6
+/**
7
+ * Notifies interested parties that desktop sharing enable/disable state is
8
+ * changed.
9
+ */
10
+export const DESKTOP_SHARING_ENABLED_CHANGED
11
+    = "conference.desktop_sharing_enabled_changed";

+ 3
- 0
conference.js ファイルの表示

@@ -588,6 +588,9 @@ export default {
588 588
                 APP.connection = connection = con;
589 589
                 this.isDesktopSharingEnabled =
590 590
                     JitsiMeetJS.isDesktopSharingEnabled();
591
+                eventEmitter.emit(
592
+                    JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
593
+                    this.isDesktopSharingEnabled);
591 594
 
592 595
                 APP.store.dispatch(showDesktopSharingButton());
593 596
 

+ 46
- 4
modules/API/API.js ファイルの表示

@@ -8,6 +8,8 @@
8 8
 
9 9
 import postisInit from 'postis';
10 10
 
11
+import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
12
+
11 13
 /**
12 14
  * List of the available commands.
13 15
  * @type {{
@@ -43,6 +45,25 @@ let postis;
43 45
  */
44 46
 let enabled = false;
45 47
 
48
+/**
49
+ * The state of screen sharing(started/stopped) before the screen sharing is
50
+ * enabled and initialized.
51
+ * NOTE: This flag help us to cache the state and use it if toggle-share-screen
52
+ * was received before the initialization.
53
+ */
54
+let initialScreenSharingState = false;
55
+
56
+/**
57
+ * Executes on toggle-share-screen command.
58
+ */
59
+function toggleScreenSharing() {
60
+    if(!APP.conference.isDesktopSharingEnabled) {
61
+        initialScreenSharingState = !initialScreenSharingState;
62
+    } else {
63
+        APP.conference.toggleScreenSharing();
64
+    }
65
+}
66
+
46 67
 function initCommands() {
47 68
     commands = {
48 69
         "display-name":
@@ -52,8 +73,7 @@ function initCommands() {
52 73
         "toggle-film-strip": APP.UI.toggleFilmstrip,
53 74
         "toggle-chat": APP.UI.toggleChat,
54 75
         "toggle-contact-list": APP.UI.toggleContactList,
55
-        "toggle-share-screen":
56
-            APP.conference.toggleScreenSharing.bind(APP.conference),
76
+        "toggle-share-screen": toggleScreenSharing,
57 77
         "video-hangup": () => APP.conference.hangup(),
58 78
         "email": APP.conference.changeLocalEmail,
59 79
         "avatar-url": APP.conference.changeLocalAvatarUrl,
@@ -97,6 +117,19 @@ function triggerEvent (name, object) {
97 117
     }
98 118
 }
99 119
 
120
+/**
121
+ * Listens for screen sharing enabled events and toggles the screen sharing if
122
+ * needed.
123
+ *
124
+ * @param {boolean} enabled - Current screen sharing enabled status.
125
+ * @returns {void}
126
+ */
127
+function onScreenSharingEnable(enabled = false) {
128
+    if(enabled && initialScreenSharingState) {
129
+        toggleScreenSharing();
130
+    }
131
+}
132
+
100 133
 class API {
101 134
     /**
102 135
      * Constructs new instance
@@ -116,7 +149,12 @@ class API {
116 149
         if(!shouldBeEnabled() && !options.forceEnable)
117 150
             return;
118 151
 
119
-        enabled = true;
152
+        if(!enabled) {
153
+            APP.conference.addListener(
154
+                JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
155
+                onScreenSharingEnable);
156
+            enabled = true;
157
+        }
120 158
 
121 159
         if(!postis) {
122 160
             this._initPostis();
@@ -233,8 +271,12 @@ class API {
233 271
      * Removes the listeners.
234 272
      */
235 273
     dispose () {
236
-        if(enabled)
274
+        if(enabled) {
237 275
             postis.destroy();
276
+            APP.conference.removeListener(
277
+                JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
278
+                onScreenSharingEnable);
279
+        }
238 280
     }
239 281
 }
240 282
 

読み込み中…
キャンセル
保存