Ping MUCs more aggressively

Stephen Paul Weber created

If we get any inbound stanza, that resets the connection ping timer, but
this is not reasonable for MUC pings since the remote MUC may have had
an issue separate from our connection.

Change summary

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 16 
1 file changed, 8 insertions(+), 8 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java 🔗

@@ -1249,14 +1249,14 @@ public class XmppConnectionService extends Service {
                         lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT,
                         account.getUuid().hashCode());
             }
-            long msToMucPing = (mLastMucPing + (Config.PING_MAX_INTERVAL * 2000L)) - SystemClock.elapsedRealtime();
-            if (msToMucPing <= 0) {
-                Log.d(Config.LOGTAG, "ping MUCs");
-                mLastMucPing = SystemClock.elapsedRealtime();
-                for (Conversation c : getConversations()) {
-                    if (c.getMode() == Conversation.MODE_MULTI && (c.getMucOptions().online() || c.getMucOptions().getError() == MucOptions.Error.SHUTDOWN)) {
-                        mucSelfPingAndRejoin(c);
-                    }
+        }
+        long msToMucPing = (mLastMucPing + (Config.PING_MAX_INTERVAL * 2000L)) - SystemClock.elapsedRealtime();
+        if (pingNow || ("ui".equals(action) && msToMucPing <= 0) || msToMucPing < -300000) {
+            Log.d(Config.LOGTAG, "ping MUCs");
+            mLastMucPing = SystemClock.elapsedRealtime();
+            for (Conversation c : getConversations()) {
+                if (c.getMode() == Conversation.MODE_MULTI && (c.getMucOptions().online() || c.getMucOptions().getError() == MucOptions.Error.SHUTDOWN)) {
+                    mucSelfPingAndRejoin(c);
                 }
             }
         }