mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-03 20:50:38 +00:00
Add initial proof of concept for http server
This commit is contained in:
parent
49aaff2bbe
commit
0338befcf3
4 changed files with 153 additions and 1 deletions
|
@ -16,6 +16,7 @@ public class Commands {
|
|||
addCommand(new DeleteLocalAccountDataCommand());
|
||||
addCommand(new FinishLinkCommand());
|
||||
addCommand(new GetUserStatusCommand());
|
||||
addCommand(new HttpServerCommand());
|
||||
addCommand(new JoinGroupCommand());
|
||||
addCommand(new JsonRpcDispatcherCommand());
|
||||
addCommand(new LinkCommand());
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package org.asamk.signal.commands;
|
||||
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.http.HttpServerHandler;
|
||||
import org.asamk.signal.manager.MultiAccountManager;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
|
||||
public class HttpServerCommand implements MultiLocalCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "http";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Takes commands via an http connection");
|
||||
subparser.addArgument("--port")
|
||||
.help("The port on which to open the HTTP service")
|
||||
.type(Integer.class)
|
||||
.setDefault(8080);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns,
|
||||
final MultiAccountManager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
|
||||
final var port = ns.getInt("port");
|
||||
|
||||
final var handler = new HttpServerHandler();
|
||||
handler.init(port, m);
|
||||
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Namespace implementation, that has plural handling for list arguments and converts camel case keys to dashed strings
|
||||
*/
|
||||
final class JsonRpcNamespace extends Namespace {
|
||||
final public class JsonRpcNamespace extends Namespace {
|
||||
|
||||
public JsonRpcNamespace(final Map<String, Object> attrs) {
|
||||
super(attrs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue