From 3804dc21a20eba112b255463dcc342aa0bf18fd3 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 15 Mar 2023 22:30:52 -0500 Subject: [PATCH] Ping all online MUCs every second max ping interval --- .../conversations/services/XmppConnectionService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index beff4f194..0d758119b 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -230,6 +230,7 @@ public class XmppConnectionService extends Service { public DatabaseBackend databaseBackend; private final ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor("ContactMerger"); private long mLastActivity = 0; + private long mLastMucPing = 0; private final FileBackend fileBackend = new FileBackend(this); private MemorizingTrustManager mMemorizingTrustManager; private final NotificationService mNotificationService = new NotificationService(this); @@ -921,6 +922,15 @@ public class XmppConnectionService extends Service { Log.d(Config.LOGTAG, account.getJid().asBareJid() + " send ping (action=" + action + ",lowTimeout=" + lowTimeout + ")"); scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode()); } + long msToMucPing = (mLastMucPing + (Config.PING_MAX_INTERVAL * 2000L)) - SystemClock.elapsedRealtime(); + if (msToMucPing <= 0) { + mLastMucPing = SystemClock.elapsedRealtime(); + for (Conversation c : getConversations()) { + if (c.getMode() == Conversation.MODE_MULTI && c.getMucOptions().online()) { + mucSelfPingAndRejoin(c); + } + } + } } WakeLockHelper.release(wakeLock); } -- 2.38.4