Переглянути джерело

feat(ParticipantConnectionStatus): add init and dispose methods

dev1
paweldomas 9 роки тому
джерело
коміт
b7e0e72f3d

+ 6
- 0
JitsiConference.js Переглянути файл

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

+ 25
- 3
modules/connectivity/ParticipantConnectionStatus.js Переглянути файл

14
 function ParticipantConnectionStatus(rtc, conference) {
14
 function ParticipantConnectionStatus(rtc, conference) {
15
     this.rtc = rtc;
15
     this.rtc = rtc;
16
     this.conference = conference;
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
  * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
45
  * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
24
  * notification over the data channel from the bridge about endpoint's
46
  * notification over the data channel from the bridge about endpoint's

Завантаження…
Відмінити
Зберегти