Adapt receive subscription notification to have payload in result field

This commit is contained in:
AsamK 2023-08-11 00:35:48 +02:00
parent 6cbd583746
commit b51c791629
2 changed files with 9 additions and 4 deletions

View file

@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
import com.fasterxml.jackson.databind.node.IntNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -86,8 +85,9 @@ public class SignalJsonRpcDispatcherHandler {
final var subscriptionId = nextSubscriptionId.getAndIncrement();
final var handlers = managers.stream().map(m -> {
final var receiveMessageHandler = new JsonReceiveMessageHandler(m, s -> {
final ContainerNode<?> params = objectMapper.valueToTree(s);
((ObjectNode) params).set("subscription", IntNode.valueOf(subscriptionId));
final var params = new ObjectNode(objectMapper.getNodeFactory());
params.set("subscription", IntNode.valueOf(subscriptionId));
params.set("result", objectMapper.valueToTree(s));
final var jsonRpcRequest = JsonRpcRequest.forNotification("receive", params, null);
try {
jsonRpcSender.sendRequest(jsonRpcRequest);