X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/b78573021d3789e1a4d3ec0db83855409674fdc1..c73c58723cc001327ed3f28cb8b98578a5437b93:/src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcDispatcherHandler.java diff --git a/src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcDispatcherHandler.java b/src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcDispatcherHandler.java index c4e9775a..12a56775 100644 --- a/src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcDispatcherHandler.java +++ b/src/main/java/org/asamk/signal/jsonrpc/SignalJsonRpcDispatcherHandler.java @@ -64,6 +64,8 @@ public class SignalJsonRpcDispatcherHandler { if (!noReceiveOnStart) { c.getAccountNumbers().stream().map(c::getManager).filter(Objects::nonNull).forEach(this::subscribeReceive); + c.addOnManagerAddedHandler(this::subscribeReceive); + c.addOnManagerRemovedHandler(this::unsubscribeReceive); } handleConnection(); @@ -76,6 +78,9 @@ public class SignalJsonRpcDispatcherHandler { subscribeReceive(m); } + final var currentThread = Thread.currentThread(); + m.addClosedListener(currentThread::interrupt); + handleConnection(); }