mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Rename JsonRpcCommand class
This commit is contained in:
parent
2879b31aba
commit
64af4914ee
5 changed files with 17 additions and 12 deletions
|
@ -3,9 +3,6 @@ package org.asamk.signal.commands;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import org.asamk.signal.OutputType;
|
import org.asamk.signal.OutputType;
|
||||||
import org.asamk.signal.OutputWriter;
|
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,8 +12,6 @@ public interface JsonRpcCommand<T> extends Command {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleCommand(T request, Manager m, OutputWriter outputWriter) throws CommandException;
|
|
||||||
|
|
||||||
default List<OutputType> getSupportedOutputTypes() {
|
default List<OutputType> getSupportedOutputTypes() {
|
||||||
return List.of(OutputType.JSON);
|
return List.of(OutputType.JSON);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.asamk.signal.manager.Manager;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface JsonRpcLocalCommand extends JsonRpcCommand<Map<String, Object>>, LocalCommand {
|
public interface JsonRpcLocalCommand extends JsonRpcSingleCommand<Map<String, Object>>, LocalCommand {
|
||||||
|
|
||||||
default TypeReference<Map<String, Object>> getRequestType() {
|
default TypeReference<Map<String, Object>> getRequestType() {
|
||||||
return new TypeReference<>() {};
|
return new TypeReference<>() {};
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.asamk.signal.commands;
|
||||||
|
|
||||||
|
import org.asamk.signal.OutputWriter;
|
||||||
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
|
|
||||||
|
public interface JsonRpcSingleCommand<T> extends JsonRpcCommand<T> {
|
||||||
|
|
||||||
|
void handleCommand(T request, Manager m, OutputWriter outputWriter) throws CommandException;
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ import org.asamk.signal.manager.Manager;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class VersionCommand implements JsonRpcCommand<Void> {
|
public class VersionCommand implements JsonRpcSingleCommand<Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.asamk.signal.JsonWriter;
|
||||||
import org.asamk.signal.OutputWriter;
|
import org.asamk.signal.OutputWriter;
|
||||||
import org.asamk.signal.commands.Command;
|
import org.asamk.signal.commands.Command;
|
||||||
import org.asamk.signal.commands.Commands;
|
import org.asamk.signal.commands.Commands;
|
||||||
import org.asamk.signal.commands.JsonRpcCommand;
|
import org.asamk.signal.commands.JsonRpcSingleCommand;
|
||||||
import org.asamk.signal.commands.SignalCreator;
|
import org.asamk.signal.commands.SignalCreator;
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
|
@ -120,7 +120,7 @@ public class SignalJsonRpcDispatcherHandler {
|
||||||
) throws JsonRpcException {
|
) throws JsonRpcException {
|
||||||
var command = getCommand(method);
|
var command = getCommand(method);
|
||||||
// TODO implement listAccounts, register, verify, link
|
// TODO implement listAccounts, register, verify, link
|
||||||
if (command instanceof JsonRpcCommand<?> jsonRpcCommand) {
|
if (command instanceof JsonRpcSingleCommand<?> jsonRpcCommand) {
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
return runCommand(objectMapper, params, new CommandRunnerImpl<>(m, jsonRpcCommand));
|
return runCommand(objectMapper, params, new CommandRunnerImpl<>(m, jsonRpcCommand));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class SignalJsonRpcDispatcherHandler {
|
||||||
return Commands.getCommand(method);
|
return Commands.getCommand(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private record CommandRunnerImpl<T>(Manager m, JsonRpcCommand<T> command) implements CommandRunner<T> {
|
private record CommandRunnerImpl<T>(Manager m, JsonRpcSingleCommand<T> command) implements CommandRunner<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(final T request, final OutputWriter outputWriter) throws CommandException {
|
public void handleCommand(final T request, final OutputWriter outputWriter) throws CommandException {
|
||||||
|
@ -227,7 +227,7 @@ public class SignalJsonRpcDispatcherHandler {
|
||||||
command.handleCommand(requestParams, outputWriter);
|
command.handleCommand(requestParams, outputWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SubscribeReceiveCommand implements JsonRpcCommand<Void> {
|
private class SubscribeReceiveCommand implements JsonRpcSingleCommand<Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -242,7 +242,7 @@ public class SignalJsonRpcDispatcherHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UnsubscribeReceiveCommand implements JsonRpcCommand<Void> {
|
private class UnsubscribeReceiveCommand implements JsonRpcSingleCommand<Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue