Преглед изворни кода

Uses the empty element with namespace for initial presence.

Fixes a problem where, sending that namespace on every presence will make the server think we are joining every time and will return us the message history for the muc.
master
damencho пре 9 година
родитељ
комит
709f12f533
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…
Откажи
Сачувај