mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Rename jsonrpc bulk to batch message
This commit is contained in:
parent
27a09fd408
commit
9c86baf0ea
5 changed files with 10 additions and 10 deletions
|
@ -623,7 +623,7 @@
|
||||||
"allDeclaredConstructors":true}
|
"allDeclaredConstructors":true}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
"name":"org.asamk.signal.jsonrpc.JsonRpcBulkMessage",
|
"name":"org.asamk.signal.jsonrpc.JsonRpcBatchMessage",
|
||||||
"allDeclaredFields":true,
|
"allDeclaredFields":true,
|
||||||
"allDeclaredMethods":true,
|
"allDeclaredMethods":true,
|
||||||
"allDeclaredConstructors":true}
|
"allDeclaredConstructors":true}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class JsonRpcBulkMessage extends JsonRpcMessage {
|
public final class JsonRpcBatchMessage extends JsonRpcMessage {
|
||||||
|
|
||||||
List<JsonNode> messages;
|
List<JsonNode> messages;
|
||||||
|
|
||||||
public JsonRpcBulkMessage(final List<JsonNode> messages) {
|
public JsonRpcBatchMessage(final List<JsonNode> messages) {
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.asamk.signal.jsonrpc;
|
package org.asamk.signal.jsonrpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a JSON-RPC (bulk) request or (bulk) response.
|
* Represents a JSON-RPC (batch) request or (batch) response.
|
||||||
* https://www.jsonrpc.org/specification
|
* https://www.jsonrpc.org/specification
|
||||||
*/
|
*/
|
||||||
public sealed abstract class JsonRpcMessage permits JsonRpcBulkMessage, JsonRpcRequest, JsonRpcResponse {
|
public sealed abstract class JsonRpcMessage permits JsonRpcBatchMessage, JsonRpcRequest, JsonRpcResponse {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class JsonRpcReader {
|
||||||
} else if (message instanceof JsonRpcResponse jsonRpcResponse) {
|
} else if (message instanceof JsonRpcResponse jsonRpcResponse) {
|
||||||
responseHandler.accept(jsonRpcResponse);
|
responseHandler.accept(jsonRpcResponse);
|
||||||
} else {
|
} else {
|
||||||
final var responseList = ((JsonRpcBulkMessage) message).getMessages().stream().map(jsonNode -> {
|
final var responseList = ((JsonRpcBatchMessage) message).getMessages().stream().map(jsonNode -> {
|
||||||
final JsonRpcRequest request;
|
final JsonRpcRequest request;
|
||||||
try {
|
try {
|
||||||
request = parseJsonRpcRequest(jsonNode);
|
request = parseJsonRpcRequest(jsonNode);
|
||||||
|
@ -61,7 +61,7 @@ public class JsonRpcReader {
|
||||||
return handleRequest(requestHandler, request);
|
return handleRequest(requestHandler, request);
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
|
||||||
jsonRpcSender.sendBulkResponses(responseList);
|
jsonRpcSender.sendBatchResponses(responseList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class JsonRpcReader {
|
||||||
null), null));
|
null), null));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new JsonRpcBulkMessage(StreamSupport.stream(jsonNode.spliterator(), false)
|
return new JsonRpcBatchMessage(StreamSupport.stream(jsonNode.spliterator(), false)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
} else if (jsonNode.isObject()) {
|
} else if (jsonNode.isObject()) {
|
||||||
if (jsonNode.has("result") || jsonNode.has("error")) {
|
if (jsonNode.has("result") || jsonNode.has("error")) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class JsonRpcSender {
|
||||||
jsonWriter.write(request);
|
jsonWriter.write(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendBulkRequests(List<JsonRpcRequest> requests) {
|
public void sendBatchRequests(List<JsonRpcRequest> requests) {
|
||||||
jsonWriter.write(requests);
|
jsonWriter.write(requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class JsonRpcSender {
|
||||||
jsonWriter.write(response);
|
jsonWriter.write(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendBulkResponses(List<JsonRpcResponse> responses) {
|
public void sendBatchResponses(List<JsonRpcResponse> responses) {
|
||||||
jsonWriter.write(responses);
|
jsonWriter.write(responses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue