mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Move receive thread handling to manager
This commit is contained in:
parent
5c389c875d
commit
fc0a9b4102
5 changed files with 156 additions and 49 deletions
|
@ -71,6 +71,9 @@ public class DaemonCommand implements MultiLocalCommand {
|
|||
|
||||
try {
|
||||
t.join();
|
||||
synchronized (this) {
|
||||
wait();
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
} catch (DBusException | IOException e) {
|
||||
|
@ -128,27 +131,11 @@ public class DaemonCommand implements MultiLocalCommand {
|
|||
|
||||
logger.info("Exported dbus object: " + objectPath);
|
||||
|
||||
final var thread = new Thread(() -> {
|
||||
while (!Thread.interrupted()) {
|
||||
try {
|
||||
final var receiveMessageHandler = outputWriter instanceof JsonWriter
|
||||
? new JsonDbusReceiveMessageHandler(m, (JsonWriter) outputWriter, conn, objectPath)
|
||||
: new DbusReceiveMessageHandler(m, (PlainTextWriter) outputWriter, conn, objectPath);
|
||||
m.receiveMessages(receiveMessageHandler);
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
logger.warn("Receiving messages failed, retrying", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
initThread.join();
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
signal.close();
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
return thread;
|
||||
final var receiveMessageHandler = outputWriter instanceof JsonWriter ? new JsonDbusReceiveMessageHandler(m,
|
||||
(JsonWriter) outputWriter,
|
||||
conn,
|
||||
objectPath) : new DbusReceiveMessageHandler(m, (PlainTextWriter) outputWriter, conn, objectPath);
|
||||
m.addReceiveHandler(receiveMessageHandler);
|
||||
return initThread;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue