Emit a reconnecting event.

This commit is contained in:
JC Brand 2016-11-23 14:50:28 +00:00
parent bfde4d3e4c
commit 0b22b5a6e0
3 changed files with 14 additions and 9 deletions

View File

@ -4,7 +4,7 @@
- #721 keepalive not working with anonymous authentication [jcbrand]
- Enable new rooms to be configured automatically, with a default config, via `rooms.open`.
For details, refer to the [relevant documentation](https://conversejs.org/docs/html/developer_api.html#the-rooms-grouping) [jcbrand]
- Bugfix: Arrays in configuration settings were ignored. [jcbrand]
- #723 Bugfix: Arrays in configuration settings were ignored. [jcbrand]
- Bugfix: Chatboxes aren't closed when logging out. [jcbrand]
- Bugfix: Trying to save data on the `ControlBox` model before `ChatBoxes`
collection has its `browserStorage` configured.
@ -15,6 +15,7 @@
- Remove (undocumented) `callback` config parameter for `converse.initialize`.
Instead, `converse.initialize` returns a promise which will resolve once
initialization is complete. [jcbrand]
- New event ['reconnecting'](https://conversejs.org/docs/html/development.html#reconnecting) [jcbrand]
## 2.0.1 (2016-11-07)
- #203 New configuration setting [muc_domain](https://conversejs.org/docs/html/configuration.html#muc_domain) [jcbrand]

View File

@ -159,6 +159,12 @@ is in `converse-notifications.js <https://github.com/jcbrand/converse.js/blob/ma
``converse.listen.on('pluginsInitialized', function (event) { ... });``
reconnecting
~~~~~~~~~~~~
Fired once converse.js has determined that it will attempt to reconnect (and
each subsequent time, if it attempts repeatedly).
reconnected
~~~~~~~~~~~

View File

@ -400,19 +400,17 @@
}, 1000);
this.onDisconnected = function (condition) {
if (converse.disconnection_cause !== converse.LOGOUT) {
if (converse.disconnection_cause === Strophe.Status.CONNFAIL && converse.auto_reconnect) {
if (converse.disconnection_cause !== converse.LOGOUT && converse.auto_reconnect) {
if (converse.disconnection_cause === Strophe.Status.CONNFAIL) {
converse.reconnect(condition);
converse.log('RECONNECTING');
return 'reconnecting';
} else if (
(converse.disconnection_cause === Strophe.Status.DISCONNECTING ||
converse.disconnection_cause === Strophe.Status.DISCONNECTED) &&
converse.auto_reconnect) {
} else if (converse.disconnection_cause === Strophe.Status.DISCONNECTING ||
converse.disconnection_cause === Strophe.Status.DISCONNECTED) {
window.setTimeout(_.partial(converse.reconnect, condition), 3000);
converse.log('RECONNECTING IN 3 SECONDS');
return 'reconnecting';
}
converse.emit('reconnecting');
return 'reconnecting';
}
delete converse.connection.reconnecting;
converse._tearDown();