mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Implement socket/tcp for daemon command
This commit is contained in:
parent
7706a02e1b
commit
81a11dc977
19 changed files with 785 additions and 240 deletions
|
@ -10,13 +10,11 @@ import org.asamk.signal.OutputWriter;
|
|||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.jsonrpc.SignalJsonRpcDispatcherHandler;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.util.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -50,21 +48,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand {
|
|||
m.setIgnoreAttachments(ignoreAttachments);
|
||||
|
||||
final var jsonOutputWriter = (JsonWriter) outputWriter;
|
||||
final Supplier<String> lineSupplier = getLineSupplier(new InputStreamReader(System.in));
|
||||
final Supplier<String> lineSupplier = IOUtils.getLineSupplier(new InputStreamReader(System.in));
|
||||
|
||||
final var handler = new SignalJsonRpcDispatcherHandler(m, jsonOutputWriter, lineSupplier);
|
||||
handler.handleConnection();
|
||||
}
|
||||
|
||||
private Supplier<String> getLineSupplier(final Reader reader) {
|
||||
final var bufferedReader = new BufferedReader(reader);
|
||||
return () -> {
|
||||
try {
|
||||
return bufferedReader.readLine();
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occurred while reading line", e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
final var handler = new SignalJsonRpcDispatcherHandler(jsonOutputWriter, lineSupplier, false);
|
||||
handler.handleConnection(m);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue