mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Reset ReconnectionManager's 'attempts' to 0
on successful reconnects. Fixes SMACK-668.
This commit is contained in:
parent
a997283304
commit
65788389ea
1 changed files with 11 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Successfully reconnected.
|
||||
attempts = 0;
|
||||
}
|
||||
catch (SmackException | IOException | XMPPException e) {
|
||||
// Fires the failed reconnection notification
|
||||
for (ConnectionListener listener : connection.connectionListeners) {
|
||||
listener.reconnectionFailed(e);
|
||||
|
|
Loading…
Reference in a new issue