瀏覽代碼

Merge pull request #175 from jitsi/fix-repeated-msgs-in-muc

Uses the empty element with namespace for initial presence.
dev1
hristoterezov 9 年之前
父節點
當前提交
bd745f70bf
共有 1 個檔案被更改,包括 12 行新增5 行删除
  1. 12
    5
      modules/xmpp/ChatRoom.js

+ 12
- 5
modules/xmpp/ChatRoom.js 查看文件

@@ -139,13 +139,20 @@ ChatRoom.prototype.sendPresence = function (fromJoin) {
139 139
     }
140 140
 
141 141
     var pres = $pres({to: to });
142
-    pres.c('x', {xmlns: this.presMap['xns']});
143 142
 
144
-    if (this.password) {
145
-        pres.c('password').t(this.password).up();
146
-    }
143
+    // xep-0045 defines: "including in the initial presence stanza an empty
144
+    // <x/> element qualified by the 'http://jabber.org/protocol/muc' namespace"
145
+    // and subsequent presences should not include that or it can be considered
146
+    // as joining, and server can send us the message history for the room on
147
+    // every presence
148
+    if (fromJoin) {
149
+        pres.c('x', {xmlns: this.presMap['xns']});
147 150
 
148
-    pres.up();
151
+        if (this.password) {
152
+            pres.c('password').t(this.password).up();
153
+        }
154
+        pres.up();
155
+    }
149 156
 
150 157
     // Send XEP-0115 'c' stanza that contains our capabilities info
151 158
     var connection = this.connection;

Loading…
取消
儲存