|
@@ -140,52 +140,38 @@ JitsiConference.prototype.isJoined = function () {
|
140
|
140
|
return this.room && this.room.joined;
|
141
|
141
|
};
|
142
|
142
|
|
143
|
|
-/**
|
144
|
|
- * Leaves the conference and calls onMemberLeft for every participant.
|
145
|
|
- */
|
146
|
|
-JitsiConference.prototype._leaveRoomAndRemoveParticipants = function () {
|
147
|
|
- // remove all participants
|
148
|
|
- this.getParticipants().forEach(function (participant) {
|
149
|
|
- this.onMemberLeft(participant.getJid());
|
150
|
|
- }.bind(this));
|
151
|
|
-
|
152
|
|
- // leave the conference
|
153
|
|
- if (this.room) {
|
154
|
|
- this.room.leave();
|
155
|
|
- }
|
156
|
|
-
|
157
|
|
- this.room = null;
|
158
|
|
-};
|
159
|
|
-
|
160
|
143
|
/**
|
161
|
144
|
* Leaves the conference.
|
162
|
145
|
* @returns {Promise}
|
163
|
146
|
*/
|
164
|
147
|
JitsiConference.prototype.leave = function () {
|
165
|
|
- var conference = this;
|
166
|
|
-
|
167
|
148
|
if (this.participantConnectionStatus) {
|
168
|
149
|
this.participantConnectionStatus.dispose();
|
169
|
150
|
this.participantConnectionStatus = null;
|
170
|
151
|
}
|
171
|
152
|
|
172
|
|
- this.statistics.stopCallStats();
|
|
153
|
+ this.getLocalTracks().forEach(track => this.onTrackRemoved(track));
|
|
154
|
+
|
173
|
155
|
this.rtc.closeAllDataChannels();
|
|
156
|
+ if(this.statistics)
|
|
157
|
+ this.statistics.dispose();
|
174
|
158
|
|
175
|
|
- return Promise.all(
|
176
|
|
- conference.getLocalTracks().map(function (track) {
|
177
|
|
- return conference.removeTrack(track);
|
178
|
|
- })
|
179
|
|
- ).then(this._leaveRoomAndRemoveParticipants.bind(this))
|
180
|
|
- .catch(function (error) {
|
181
|
|
- logger.error(error);
|
182
|
|
- GlobalOnErrorHandler.callUnhandledRejectionHandler(
|
183
|
|
- {promise: this, reason: error});
|
184
|
|
- // We are proceeding with leaving the conference because room.leave may
|
185
|
|
- // succeed.
|
186
|
|
- this._leaveRoomAndRemoveParticipants();
|
187
|
|
- return Promise.resolve();
|
188
|
|
- }.bind(this));
|
|
159
|
+ // leave the conference
|
|
160
|
+ if (this.room) {
|
|
161
|
+ let room = this.room;
|
|
162
|
+ this.room = null;
|
|
163
|
+ return room.leave().catch(() => {
|
|
164
|
+ // remove all participants because currently the conference won't
|
|
165
|
+ // be usable anyway. This is done on success automatically by the
|
|
166
|
+ // ChatRoom instance.
|
|
167
|
+ this.getParticipants().forEach(
|
|
168
|
+ participant => this.onMemberLeft(participant.getJid()));
|
|
169
|
+ });
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ // If this.room == null we are calling second time leave().
|
|
173
|
+ return Promise.reject(
|
|
174
|
+ new Error("The conference is has been already left"));
|
189
|
175
|
};
|
190
|
176
|
|
191
|
177
|
/**
|