Reset ReconnectionManager's 'attempts' to 0

on successful reconnects. Fixes SMACK-668.
This commit is contained in:
Florian Schmaus 2015-06-27 14:25:19 +02:00
parent a997283304
commit 65788389ea
1 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import org.jivesoftware.smack.XMPPException.StreamErrorException;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.util.Async;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.Random;
@ -239,8 +240,17 @@ public class ReconnectionManager {
if (isReconnectionPossible(connection)) {
connection.connect();
}
// TODO Starting with Smack 4.2, connect() will no
// longer login automatically. So change this and the
// previous lines to connection.connect().login() in the
// 4.2, or any later, branch.
if (!connection.isAuthenticated()) {
connection.login();
}
// Successfully reconnected.
attempts = 0;
}
catch (Exception e) {
catch (SmackException | IOException | XMPPException e) {
// Fires the failed reconnection notification
for (ConnectionListener listener : connection.connectionListeners) {
listener.reconnectionFailed(e);