mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Implement unregister command for jsonrpc and dbus daemon
This commit is contained in:
parent
b78573021d
commit
c73c58723c
11 changed files with 98 additions and 9 deletions
|
@ -132,6 +132,12 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
runDbusSingleAccount(m, false, receiveMode != ReceiveMode.ON_START);
|
||||
}
|
||||
|
||||
m.addClosedListener(() -> {
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
});
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
|
@ -230,7 +236,6 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
}
|
||||
|
||||
private void runSocket(final ServerSocketChannel serverChannel, Consumer<SocketChannel> socketHandler) {
|
||||
final var mainThread = Thread.currentThread();
|
||||
new Thread(() -> {
|
||||
while (true) {
|
||||
final SocketChannel channel;
|
||||
|
@ -241,7 +246,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
logger.info("Accepted new client: " + clientString);
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to accept new socket connection", e);
|
||||
mainThread.notifyAll();
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
new Thread(() -> {
|
||||
|
@ -292,6 +299,17 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
}
|
||||
}
|
||||
});
|
||||
c.addOnManagerRemovedHandler(m -> {
|
||||
final var path = DbusConfig.getObjectPath(m.getSelfNumber());
|
||||
try {
|
||||
final var object = connection.getExportedObject(null, path);
|
||||
if (object instanceof DbusSignalImpl dbusSignal) {
|
||||
dbusSignal.close();
|
||||
}
|
||||
} catch (DBusException ignored) {
|
||||
}
|
||||
connection.unExportObject(path);
|
||||
});
|
||||
|
||||
final var initThreads = c.getAccountNumbers()
|
||||
.stream()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue