Browse Source

remove all participants and tracks when leaving the room

tags/v0.0.2
isymchych 8 years ago
parent
commit
9df12f9fa2
3 changed files with 40 additions and 4 deletions
  1. 17
    0
      .editorconfig
  2. 22
    3
      JitsiConference.js
  3. 1
    1
      doc/API.md

+ 17
- 0
.editorconfig View File

@@ -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

+ 22
- 3
JitsiConference.js View File

@@ -82,11 +82,30 @@ JitsiConference.prototype.isJoined = function () {
82 82
 
83 83
 /**
84 84
  * Leaves the conference.
85
+ * @returns {Promise}
85 86
  */
86 87
 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
+    });
90 109
 };
91 110
 
92 111
 /**

+ 1
- 1
doc/API.md View File

@@ -187,7 +187,7 @@ The object represents a conference. We have the following methods to control the
187 187
 1. join(password) - Joins the conference
188 188
     - password - string of the password. This parameter is not mandatory.
189 189
 
190
-2. leave() - leaves the conference
190
+2. leave() - leaves the conference. Returns Promise.
191 191
 
192 192
 4. getLocalTracks() - Returns array with JitsiTrack objects for the local streams.
193 193
 

Loading…
Cancel
Save