use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.response.SubscriptionResponse in project besu by hyperledger.
the class SubscriptionManagerSendMessageTest method shouldSendMessageOnTheConnectionIdEventBusAddressForExistingSubscription.
@Test
@Ignore
public void shouldSendMessageOnTheConnectionIdEventBusAddressForExistingSubscription(final TestContext context) {
final String connectionId = UUID.randomUUID().toString();
final SubscribeRequest subscribeRequest = new SubscribeRequest(SubscriptionType.SYNCING, null, null, connectionId);
final JsonRpcResult expectedResult = mock(JsonRpcResult.class);
final Subscription subscription = new Subscription(1L, connectionId, SubscriptionType.SYNCING, false);
final SubscriptionResponse expectedResponse = new SubscriptionResponse(subscription, expectedResult);
final Long subscriptionId = subscriptionManager.subscribe(subscribeRequest);
final Async async = context.async();
vertx.eventBus().consumer(connectionId).handler(msg -> {
context.assertEquals(Json.encode(expectedResponse), msg.body());
async.complete();
}).completionHandler(v -> subscriptionManager.sendMessage(subscriptionId, expectedResult));
async.awaitSuccess(VERTX_AWAIT_TIMEOUT_MILLIS);
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.response.SubscriptionResponse in project besu by hyperledger.
the class SubscriptionManager method sendMessage.
public void sendMessage(final Long subscriptionId, final JsonRpcResult msg) {
final Subscription subscription = subscriptions.get(subscriptionId);
if (subscription != null) {
final SubscriptionResponse response = new SubscriptionResponse(subscription, msg);
vertx.eventBus().send(subscription.getConnectionId(), Json.encode(response));
}
}
Aggregations