Commit 04978265 authored by JC Brand's avatar JC Brand

Merge pull request #559 from m0cs/fix_reconnect_timeout

A cleaner reconnect timeout.
parents dd6eae7f b645d8fb
...@@ -434,6 +434,7 @@ ...@@ -434,6 +434,7 @@
*/ */
this.send_initial_presence = true; this.send_initial_presence = true;
this.msg_counter = 0; this.msg_counter = 0;
this.reconnectTimeout = undefined;
// Module-level functions // Module-level functions
// ---------------------- // ----------------------
...@@ -605,7 +606,8 @@ ...@@ -605,7 +606,8 @@
this.reconnect = function (condition) { this.reconnect = function (condition) {
converse.log('Attempting to reconnect in 5 seconds'); converse.log('Attempting to reconnect in 5 seconds');
converse.giveFeedback(__('Attempting to reconnect in 5 seconds'), 'error'); converse.giveFeedback(__('Attempting to reconnect in 5 seconds'), 'error');
setTimeout(function () { clearTimeout(converse.reconnectTimeout);
converse.reconnectTimeout = setTimeout(function () {
if (converse.authentication !== "prebind") { if (converse.authentication !== "prebind") {
this.connection.connect( this.connection.connect(
this.connection.jid, this.connection.jid,
...@@ -638,6 +640,10 @@ ...@@ -638,6 +640,10 @@
// By default we always want to send out an initial presence stanza. // By default we always want to send out an initial presence stanza.
converse.send_initial_presence = true; converse.send_initial_presence = true;
delete converse.disconnection_cause; delete converse.disconnection_cause;
if (!!converse.reconnectTimeout) {
clearTimeout(converse.reconnectTimeout);
delete converse.reconnectTimeout;
}
if ((typeof reconnect !== 'undefined') && (reconnect)) { if ((typeof reconnect !== 'undefined') && (reconnect)) {
converse.log(status === Strophe.Status.CONNECTED ? 'Reconnected' : 'Reattached'); converse.log(status === Strophe.Status.CONNECTED ? 'Reconnected' : 'Reattached');
converse.onReconnected(); converse.onReconnected();
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
See [include_offline_state](https://conversejs.org/docs/html/configuration.html#include_offline_state) for details. [jcbrand] See [include_offline_state](https://conversejs.org/docs/html/configuration.html#include_offline_state) for details. [jcbrand]
- A chatroom invite might come from someone not in your roster list. [ben] - A chatroom invite might come from someone not in your roster list. [ben]
- #487 Empty the resources array when the resource is null [rlanvin] - #487 Empty the resources array when the resource is null [rlanvin]
- #559 Optimize auto_reconnect function. [m0cs]
## 0.10.0 (2015-11-05) ## 0.10.0 (2015-11-05)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment