Procházet zdrojové kódy

feat(ParticipantConnectionStatus): add init and dispose methods

dev1
paweldomas před 9 roky
rodič
revize
b7e0e72f3d

+ 6
- 0
JitsiConference.js Zobrazit soubor

@@ -96,6 +96,7 @@ JitsiConference.prototype._init = function (options) {
96 96
 
97 97
     this.participantConnectionStatus
98 98
         = new ParticipantConnectionStatus(this.rtc, this);
99
+    this.participantConnectionStatus.init();
99 100
 
100 101
     if(!this.statistics) {
101 102
         this.statistics = new Statistics(this.xmpp, {
@@ -156,6 +157,11 @@ JitsiConference.prototype._leaveRoomAndRemoveParticipants = function () {
156 157
 JitsiConference.prototype.leave = function () {
157 158
     var conference = this;
158 159
 
160
+    if (this.participantConnectionStatus) {
161
+        this.participantConnectionStatus.dispose();
162
+        this.participantConnectionStatus = null;
163
+    }
164
+
159 165
     this.statistics.stopCallStats();
160 166
     this.rtc.closeAllDataChannels();
161 167
 

+ 25
- 3
modules/connectivity/ParticipantConnectionStatus.js Zobrazit soubor

@@ -14,11 +14,33 @@ import * as JitsiConferenceEvents from "../../JitsiConferenceEvents";
14 14
 function ParticipantConnectionStatus(rtc, conference) {
15 15
     this.rtc = rtc;
16 16
     this.conference = conference;
17
-    rtc.addListener(
18
-        RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
19
-        this.onEndpointConnStatusChanged.bind(this));
20 17
 }
21 18
 
19
+/**
20
+ * Initializes <tt>ParticipantConnectionStatus</tt> and bind required event
21
+ * listeners.
22
+ */
23
+ParticipantConnectionStatus.prototype.init = function() {
24
+
25
+    this._onEndpointConnStatusChanged
26
+        = this.onEndpointConnStatusChanged.bind(this);
27
+
28
+    this.rtc.addListener(
29
+        RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
30
+        this._onEndpointConnStatusChanged);
31
+};
32
+
33
+/**
34
+ * Removes all event listeners and disposes of all resources held by this
35
+ * instance.
36
+ */
37
+ParticipantConnectionStatus.prototype.dispose = function () {
38
+
39
+    this.rtc.removeListener(
40
+        RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
41
+        this._onEndpointConnStatusChanged);
42
+};
43
+
22 44
 /**
23 45
  * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
24 46
  * notification over the data channel from the bridge about endpoint's

Načítá se…
Zrušit
Uložit