浏览代码

fix(avmoderation,breakout-rooms) dispose handlers when leaving

Both of this features listen for events in the XMPP connection. Thus, if we join
another meeting over the same connection we might still receive some events on
the old event handler.

Stop listening for events from the components as soon as the leave operation is
triggered.
dev1
Saúl Ibarra Corretgé 3 年前
父节点
当前提交
0d111e4c77
共有 3 个文件被更改,包括 21 次插入2 次删除
  1. 9
    1
      modules/xmpp/AVModeration.js
  2. 9
    1
      modules/xmpp/BreakoutRooms.js
  3. 3
    0
      modules/xmpp/ChatRoom.js

+ 9
- 1
modules/xmpp/AVModeration.js 查看文件

29
         this._whitelistAudio = [];
29
         this._whitelistAudio = [];
30
         this._whitelistVideo = [];
30
         this._whitelistVideo = [];
31
 
31
 
32
-        this._xmpp.addListener(XMPPEvents.AV_MODERATION_RECEIVED, this._onMessage.bind(this));
32
+        this._onMessage = this._onMessage.bind(this);
33
+        this._xmpp.addListener(XMPPEvents.AV_MODERATION_RECEIVED, this._onMessage);
34
+    }
35
+
36
+    /**
37
+     * Stops listening for events.
38
+     */
39
+    dispose() {
40
+        this._xmpp.removeListener(XMPPEvents.AV_MODERATION_RECEIVED, this._onMessage);
33
     }
41
     }
34
 
42
 
35
     /**
43
     /**

+ 9
- 1
modules/xmpp/BreakoutRooms.js 查看文件

29
     constructor(room) {
29
     constructor(room) {
30
         this.room = room;
30
         this.room = room;
31
 
31
 
32
-        this.room.xmpp.addListener(XMPPEvents.BREAKOUT_ROOMS_EVENT, this._handleMessages.bind(this));
32
+        this._handleMessages = this._handleMessages.bind(this);
33
+        this.room.xmpp.addListener(XMPPEvents.BREAKOUT_ROOMS_EVENT, this._handleMessages);
33
 
34
 
34
         this._rooms = {};
35
         this._rooms = {};
35
     }
36
     }
36
 
37
 
38
+    /**
39
+     * Stops listening for events.
40
+     */
41
+    dispose() {
42
+        this.room.xmpp.removeListener(XMPPEvents.BREAKOUT_ROOMS_EVENT, this._handleMessages);
43
+    }
44
+
37
     /**
45
     /**
38
      * Creates a breakout room with the given subject.
46
      * Creates a breakout room with the given subject.
39
      *
47
      *

+ 3
- 0
modules/xmpp/ChatRoom.js 查看文件

1849
      * rejected.
1849
      * rejected.
1850
      */
1850
      */
1851
     leave() {
1851
     leave() {
1852
+        this.avModeration.dispose();
1853
+        this.breakoutRooms.dispose();
1854
+
1852
         const promises = [];
1855
         const promises = [];
1853
 
1856
 
1854
         this.lobby?.lobbyRoom && promises.push(this.lobby.leave());
1857
         this.lobby?.lobbyRoom && promises.push(this.lobby.leave());

正在加载...
取消
保存