ソースを参照

Fixes issue with not completing promise for remove/add track and conference leave

dev1
hristoterezov 9年前
コミット
4861c2a9fc
2個のファイルの変更37行の追加13行の削除
  1. 23
    12
      JitsiConference.js
  2. 14
    1
      modules/xmpp/JingleSessionPC.js

+ 23
- 12
JitsiConference.js ファイルの表示

@@ -87,6 +87,21 @@ JitsiConference.prototype.isJoined = function () {
87 87
     return this.room && this.room.joined;
88 88
 };
89 89
 
90
+/**
91
+ * Leaves the conference and calls onMemberLeft for every participant.
92
+ */
93
+JitsiConference.prototype._leaveRoomAndRemoveParticipants = function () {
94
+    // leave the conference
95
+    if (this.room) {
96
+        this.room.leave();
97
+    }
98
+
99
+    this.room = null;
100
+    // remove all participants
101
+    this.getParticipants().forEach(function (participant) {
102
+        this.onMemberLeft(participant.getJid());
103
+    }.bind(this));
104
+}
90 105
 /**
91 106
  * Leaves the conference.
92 107
  * @returns {Promise}
@@ -98,18 +113,14 @@ JitsiConference.prototype.leave = function () {
98 113
         conference.getLocalTracks().map(function (track) {
99 114
             return conference.removeTrack(track);
100 115
         })
101
-    ).then(function () {
102
-        // leave the conference
103
-        if (conference.room) {
104
-            conference.room.leave();
105
-        }
106
-
107
-        conference.room = null;
108
-        // remove all participants
109
-        conference.getParticipants().forEach(function (participant) {
110
-            conference.onMemberLeft(participant.getJid());
111
-        });
112
-    });
116
+    ).then(this._leaveRoomAndRemoveParticipants.bind(this))
117
+    .catch(function (error) {
118
+        logger.error(error);
119
+        // We are proceeding with leaving the conference because room.leave may
120
+        // succeed.
121
+        this._leaveRoomAndRemoveParticipants();
122
+        return Promise.resolve();
123
+    }.bind(this));
113 124
 };
114 125
 
115 126
 /**

+ 14
- 1
modules/xmpp/JingleSessionPC.js ファイルの表示

@@ -943,6 +943,11 @@ JingleSessionPC.prototype.addStream = function (stream, callback, ssrcInfo,
943 943
         return;
944 944
     }
945 945
 
946
+    if(this.modifySourcesQueue.paused) {
947
+        throw new Error("modifySourcesQueue paused");
948
+        return;
949
+    }
950
+
946 951
     this.modifyingLocalStreams = true;
947 952
     var self = this;
948 953
     this.modifySourcesQueue.push(function() {
@@ -985,8 +990,10 @@ JingleSessionPC.prototype.removeStream = function (stream, callback, ssrcInfo) {
985 990
         }
986 991
         if (RTCBrowserType.getBrowserType() ===
987 992
                 RTCBrowserType.RTC_BROWSER_FIREFOX) {
988
-            if(!stream)//There is nothing to be changed
993
+            if(!stream) {//There is nothing to be changed
994
+                callback();
989 995
                 return;
996
+            }
990 997
             var sender = null;
991 998
             // On Firefox we don't replace MediaStreams as this messes up the
992 999
             // m-lines (which can't be removed in Plan Unified) and brings a lot
@@ -1002,6 +1009,7 @@ JingleSessionPC.prototype.removeStream = function (stream, callback, ssrcInfo) {
1002 1009
 
1003 1010
             if(!track) {
1004 1011
                 logger.log("Cannot remove tracks: no tracks.");
1012
+                callback();
1005 1013
                 return;
1006 1014
             }
1007 1015
 
@@ -1032,6 +1040,11 @@ JingleSessionPC.prototype.removeStream = function (stream, callback, ssrcInfo) {
1032 1040
         return;
1033 1041
     }
1034 1042
 
1043
+    if(this.modifySourcesQueue.paused) {
1044
+        throw new Error("modifySourcesQueue paused");
1045
+        return;
1046
+    }
1047
+
1035 1048
     this.modifyingLocalStreams = true;
1036 1049
     var self = this;
1037 1050
     this.modifySourcesQueue.push(function() {

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