From 9b102c49d06bd6dcd59f032ddd17663f47991118 Mon Sep 17 00:00:00 2001 From: AsamK Date: Sun, 24 Oct 2021 19:16:35 +0200 Subject: [PATCH] Adapt behavior of receive command as dbus client to match normal mode --- .../org/asamk/signal/commands/ReceiveCommand.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/asamk/signal/commands/ReceiveCommand.java b/src/main/java/org/asamk/signal/commands/ReceiveCommand.java index e72d8090..6b2e497e 100644 --- a/src/main/java/org/asamk/signal/commands/ReceiveCommand.java +++ b/src/main/java/org/asamk/signal/commands/ReceiveCommand.java @@ -128,11 +128,18 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand { logger.error("Dbus client failed", e); throw new UnexpectedErrorException("Dbus client failed", e); } + + double timeout = ns.getDouble("timeout"); + long timeoutMilliseconds = timeout < 0 ? 10000 : (long) (timeout * 1000); + while (true) { try { - Thread.sleep(10000); + Thread.sleep(timeoutMilliseconds); } catch (InterruptedException ignored) { - return; + break; + } + if (timeout >= 0) { + break; } } }