Просмотр исходного кода

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

Uses the empty element with namespace for initial presence.
dev1
hristoterezov 9 лет назад
Родитель
Сommit
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;

Загрузка…
Отмена
Сохранить