From: AsamK Date: Sun, 24 Oct 2021 17:16:35 +0000 (+0200) Subject: Adapt behavior of receive command as dbus client to match normal mode X-Git-Tag: v0.9.2~3 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/9b102c49d06bd6dcd59f032ddd17663f47991118?ds=sidebyside Adapt behavior of receive command as dbus client to match normal mode --- 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; } } }