]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/ReceiveCommand.java
Adapt behavior of receive command as dbus client to match normal mode
[signal-cli] / 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;
             }
         }
     }