瀏覽代碼

Do not deregister Strophe listener on missing room, fix removeCommandListener

dev1
Papp István Péter 6 年之前
父節點
當前提交
2d06c3e244
共有 2 個文件被更改,包括 9 次插入9 次删除
  1. 3
    2
      JitsiConference.js
  2. 6
    7
      modules/xmpp/strophe.emuc.js

+ 3
- 2
JitsiConference.js 查看文件

@@ -685,10 +685,11 @@ JitsiConference.prototype.addCommandListener = function(command, handler) {
685 685
 /**
686 686
   * Removes command  listener
687 687
   * @param command {String} the name of the command
688
+  * @param handler {Function} handler to remove for the command
688 689
   */
689
-JitsiConference.prototype.removeCommandListener = function(command) {
690
+JitsiConference.prototype.removeCommandListener = function(command, handler) {
690 691
     if (this.room) {
691
-        this.room.removePresenceListener(command);
692
+        this.room.removePresenceListener(command, handler);
692 693
     }
693 694
 };
694 695
 

+ 6
- 7
modules/xmpp/strophe.emuc.js 查看文件

@@ -91,7 +91,7 @@ class MucConnectionPlugin extends ConnectionPluginListenable {
91 91
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
92 92
 
93 93
         if (!room) {
94
-            return;
94
+            return true;
95 95
         }
96 96
 
97 97
         // Parse status.
@@ -114,7 +114,7 @@ class MucConnectionPlugin extends ConnectionPluginListenable {
114 114
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
115 115
 
116 116
         if (!room) {
117
-            return;
117
+            return true;
118 118
         }
119 119
 
120 120
         room.onPresenceUnavailable(pres, from);
@@ -131,7 +131,7 @@ class MucConnectionPlugin extends ConnectionPluginListenable {
131 131
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
132 132
 
133 133
         if (!room) {
134
-            return;
134
+            return true;
135 135
         }
136 136
 
137 137
         room.onPresenceError(pres, from);
@@ -149,7 +149,7 @@ class MucConnectionPlugin extends ConnectionPluginListenable {
149 149
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
150 150
 
151 151
         if (!room) {
152
-            return;
152
+            return true;
153 153
         }
154 154
 
155 155
         room.onMessage(msg, from);
@@ -165,10 +165,9 @@ class MucConnectionPlugin extends ConnectionPluginListenable {
165 165
         const from = iq.getAttribute('from');
166 166
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
167 167
 
168
-        // XXX What are the semantics of the return value? Why is it sometimes
169
-        // undefined and sometimes a boolean?
168
+        // Returning false would result in the listener being deregistered by Strophe
170 169
         if (!room) {
171
-            return;
170
+            return true;
172 171
         }
173 172
 
174 173
         room.onMute(iq);

Loading…
取消
儲存