1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +01:00

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

View file

@ -20,6 +20,7 @@ import org.jivesoftware.smack.XMPPException.StreamErrorException;
import org.jivesoftware.smack.packet.StreamError; import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.util.Async; import org.jivesoftware.smack.util.Async;
import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -239,8 +240,17 @@ public class ReconnectionManager {
if (isReconnectionPossible(connection)) { if (isReconnectionPossible(connection)) {
connection.connect(); 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();
} }
catch (Exception e) { // Successfully reconnected.
attempts = 0;
}
catch (SmackException | IOException | XMPPException e) {
// Fires the failed reconnection notification // Fires the failed reconnection notification
for (ConnectionListener listener : connection.connectionListeners) { for (ConnectionListener listener : connection.connectionListeners) {
listener.reconnectionFailed(e); listener.reconnectionFailed(e);