Browse Source

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 years ago
parent
commit
709f12f533
1 changed files with 12 additions and 5 deletions
  1. 12
    5
      modules/xmpp/ChatRoom.js

+ 12
- 5
modules/xmpp/ChatRoom.js View File

139
     }
139
     }
140
 
140
 
141
     var pres = $pres({to: to });
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
     // Send XEP-0115 'c' stanza that contains our capabilities info
157
     // Send XEP-0115 'c' stanza that contains our capabilities info
151
     var connection = this.connection;
158
     var connection = this.connection;

Loading…
Cancel
Save