Commit 4070b26c authored by Grigory Fedorov's avatar Grigory Fedorov

PingManager ping failed listener registration moved from ConnectionManager to ConnectionThread.

parent 5dcc24e0
......@@ -209,14 +209,6 @@ public class ConnectionManager implements OnInitializedListener, OnCloseListener
for (OnConnectedListener listener : Application.getInstance().getManagers(OnConnectedListener.class)) {
listener.onConnected(connectionThread.getConnectionItem());
}
org.jivesoftware.smackx.ping.PingManager.getInstanceFor(connectionThread.getXMPPConnection()).registerPingFailedListener(new PingFailedListener() {
@Override
public void pingFailed() {
LogManager.i(this, "pingFailed for " + connectionThread.getConnectionItem().getRealJid());
connectionThread.getConnectionItem().forceReconnect();
}
});
}
public void onAuthorized(ConnectionThread connectionThread) {
......
......@@ -14,8 +14,6 @@
*/
package com.xabber.android.data.connection;
import android.os.Build;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -26,7 +24,9 @@ import com.xabber.android.data.account.OAuthManager;
import com.xabber.android.data.account.OAuthResult;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.StanzaFilter;
......@@ -37,6 +37,7 @@ import org.jivesoftware.smack.roster.Roster;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
import org.jivesoftware.smackx.iqregister.AccountManager;
import org.jivesoftware.smackx.ping.PingFailedListener;
import org.xbill.DNS.Record;
import java.io.IOException;
......@@ -64,8 +65,8 @@ import de.duenndns.ssl.MemorizingTrustManager;
* @author alexander.ivanov
*/
public class ConnectionThread implements
org.jivesoftware.smack.ConnectionListener,
org.jivesoftware.smack.StanzaListener {
ConnectionListener,
StanzaListener, PingFailedListener {
private static Pattern ADDRESS_AND_PORT = Pattern.compile("^(.*):(\\d+)$");
......@@ -372,6 +373,8 @@ public class ConnectionThread implements
xmppConnection.addAsyncStanzaListener(this, ACCEPT_ALL);
xmppConnection.addConnectionListener(this);
org.jivesoftware.smackx.ping.PingManager.getInstanceFor(xmppConnection).registerPingFailedListener(this);
// We use own roster management.
Roster.getInstanceFor(xmppConnection).setRosterLoadedAtLogin(false);
......@@ -728,6 +731,12 @@ public class ConnectionThread implements
});
}
@Override
public void pingFailed() {
LogManager.i(this, "pingFailed for " + getConnectionItem().getRealJid());
getConnectionItem().forceReconnect();
}
/**
* Filter to accept all packets.
*
......
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