diff --git a/app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java b/app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java index f9a57c88a..254c97dc9 100644 --- a/app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java +++ b/app/src/main/java/org/kontalk/service/msgcenter/MessageCenterService.java @@ -55,6 +55,8 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.iqlast.packet.LastActivity; import org.jivesoftware.smackx.iqversion.VersionManager; +import org.jivesoftware.smackx.ping.PingFailedListener; +import org.jivesoftware.smackx.ping.PingManager; import org.jivesoftware.smackx.ping.android.ServerPingWithAlarmManager; import org.jivesoftware.smackx.receipts.DeliveryReceipt; import org.jivesoftware.smackx.receipts.DeliveryReceiptRequest; @@ -980,6 +982,15 @@ public synchronized void created(XMPPConnection connection) { // enable ping manager ServerPingWithAlarmManager.getInstanceFor(connection).setEnabled(true); + PingManager.getInstanceFor(connection) + .registerPingFailedListener(new PingFailedListener() { + @Override + public void pingFailed() { + Log.v(TAG, "ping failed, restarting message center"); + // restart message center + restart(getApplicationContext()); + } + }); PacketFilter filter;