mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-17 14:14:24 +01:00
Implement unregister command for jsonrpc and dbus daemon
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user