浏览代码

muc: Fix: after reconnecting, already open room didn't receive new messages

JC Brand 8 年之前
父节点
当前提交
66fd9a9f28
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 6 2
      src/converse-core.js
  2. 2 0
      src/converse-muc.js

+ 6 - 2
src/converse-core.js

@@ -2069,7 +2069,9 @@
                         "Either when calling converse.initialize, or when calling " +
                         "Either when calling converse.initialize, or when calling " +
                         "_converse.api.user.login.");
                         "_converse.api.user.login.");
                 }
                 }
-                this.connection.reset();
+                if (!this.connection.reconnecting) {
+                    this.connection.reset();
+                }
                 this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged);
                 this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged);
             } else if (this.authentication === _converse.LOGIN) {
             } else if (this.authentication === _converse.LOGIN) {
                 var password = _.isNil(credentials) ? (_converse.connection.pass || this.password) : credentials.password;
                 var password = _.isNil(credentials) ? (_converse.connection.pass || this.password) : credentials.password;
@@ -2088,7 +2090,9 @@
                 } else {
                 } else {
                     this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
                     this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
                 }
                 }
-                this.connection.reset();
+                if (!this.connection.reconnecting) {
+                    this.connection.reset();
+                }
                 this.connection.connect(this.jid, password, this.onConnectStatusChanged);
                 this.connection.connect(this.jid, password, this.onConnectStatusChanged);
             }
             }
         };
         };

+ 2 - 0
src/converse-muc.js

@@ -2785,7 +2785,9 @@
                 _converse.chatboxviews.each(function (view) {
                 _converse.chatboxviews.each(function (view) {
                     if (view.model.get('type') === CHATROOMS_TYPE) {
                     if (view.model.get('type') === CHATROOMS_TYPE) {
                         view.model.save('connection_status', ROOMSTATUS.DISCONNECTED);
                         view.model.save('connection_status', ROOMSTATUS.DISCONNECTED);
+                        view.registerHandlers();
                         view.join();
                         view.join();
+                        view.fetchMessages();
                     }
                     }
                 });
                 });
             };
             };