Skip to content

Commit 9df12f9

Browse files
author
isymchych
committed
remove all participants and tracks when leaving the room
1 parent 4220f6c commit 9df12f9

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 4
8+
indent_style = space
9+
max_line_length = 80
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = 120
14+
trim_trailing_whitespace = false
15+
16+
[COMMIT_EDITMSG]
17+
max_line_length = 80

JitsiConference.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,30 @@ JitsiConference.prototype.isJoined = function () {
8282

8383
/**
8484
* Leaves the conference.
85+
* @returns {Promise}
8586
*/
8687
JitsiConference.prototype.leave = function () {
87-
if(this.xmpp && this.room)
88-
this.xmpp.leaveRoom(this.room.roomjid);
89-
this.room = null;
88+
var conference = this;
89+
90+
// leave the conference
91+
if (conference.xmpp && conference.room) {
92+
conference.xmpp.leaveRoom(conference.room.roomjid);
93+
}
94+
95+
conference.room = null;
96+
97+
// remove local tracks
98+
return Promise.all(
99+
conference.getLocalTracks().map(function (track) {
100+
return conference.removeTrack(track);
101+
})
102+
).then(function () {
103+
104+
// remove all participants
105+
conference.getParticipants().forEach(function (participant) {
106+
conference.onMemberLeft(participant.getJid());
107+
});
108+
});
90109
};
91110

92111
/**

doc/API.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The object represents a conference. We have the following methods to control the
187187
1. join(password) - Joins the conference
188188
- password - string of the password. This parameter is not mandatory.
189189

190-
2. leave() - leaves the conference
190+
2. leave() - leaves the conference. Returns Promise.
191191

192192
4. getLocalTracks() - Returns array with JitsiTrack objects for the local streams.
193193

0 commit comments

Comments
 (0)