org.web3j.protocol.core.Request.getId()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.web3j.protocol.core.Request.getId方法的一些代码示例,展示了Request.getId的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getId方法的具体详情如下:
包路径:org.web3j.protocol.core.Request
类名称:Request
方法名:getId

Request.getId介绍

暂无

代码示例

代码示例来源:origin: web3j/web3j

private <T extends Notification<?>> void subscribeToEventsStream(
    Request request,
    BehaviorSubject<T> subject, Class<T> responseType) {
  subscriptionRequestForId.put(
      request.getId(),
      new WebSocketSubscription<>(subject, responseType));
  try {
    send(request, EthSubscribe.class);
  } catch (IOException e) {
    log.error("Failed to subscribe to RPC events with request id {}",
        request.getId());
    subject.onError(e);
  }
}

代码示例来源:origin: web3j/web3j

@Override
public <T extends Response> CompletableFuture<T> sendAsync(
    Request request,
    Class<T> responseType) {
  CompletableFuture<T> result = new CompletableFuture<>();
  long requestId = request.getId();
  requestForId.put(requestId, new WebSocketRequest<>(result, responseType));
  try {
    sendRequest(request, requestId);
  } catch (IOException e) {
    closeRequest(requestId, e);
  }
  return result;
}

代码示例来源:origin: web3j/web3j

@Test
public void testWaitingForReplyToSentRequest() throws Exception {
  service.sendAsync(request, Web3ClientVersion.class);
  assertTrue(service.isWaitingForReply(request.getId()));
}

相关文章