]> nmode's Git Repositories - signal-cli/commitdiff
Adapt behavior of receive command as dbus client to match normal mode
authorAsamK <asamk@gmx.de>
Sun, 24 Oct 2021 17:16:35 +0000 (19:16 +0200)
committerAsamK <asamk@gmx.de>
Sun, 24 Oct 2021 17:16:35 +0000 (19:16 +0200)
src/main/java/org/asamk/signal/commands/ReceiveCommand.java

index e72d809027b9075ef678ac0cd756d34434ebfc69..6b2e497e10b3fd8953bf1960275de1fc497f2c7a 100644 (file)
@@ -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;
             }
         }
     }