From 2b0989adfe84340df9001c502046581bad1e2208 Mon Sep 17 00:00:00 2001 From: AsamK Date: Tue, 9 Nov 2021 18:28:14 +0100 Subject: [PATCH] Disconnect websocket when receiving is done --- lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java index 9e81f206..94a3f4be 100644 --- a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java @@ -920,6 +920,7 @@ public class ManagerImpl implements Manager { return; } receiveThread = new Thread(() -> { + logger.debug("Starting receiving messages"); while (!Thread.interrupted()) { try { receiveMessagesInternal(1L, TimeUnit.HOURS, false, (envelope, e) -> { @@ -938,12 +939,14 @@ public class ManagerImpl implements Manager { logger.warn("Receiving messages failed, retrying", e); } } + logger.debug("Finished receiving messages"); hasCaughtUpWithOldMessages = false; synchronized (messageHandlers) { receiveThread = null; // Check if in the meantime another handler has been registered if (!messageHandlers.isEmpty()) { + logger.debug("Another handler has been registered, starting receive thread again"); startReceiveThreadIfRequired(); } } @@ -1114,6 +1117,7 @@ public class ManagerImpl implements Manager { } handleQueuedActions(queuedActions); queuedActions.clear(); + dependencies.getSignalWebSocket().disconnect(); } @Override