Exemple #1
0
  public CompletableFuture<TestStackResponse> testStack(int input) {
    RequestHeader header =
        new RequestHeader(
            NodeId.NULL_VALUE,
            DateTime.now(),
            uint(requestHandle.getAndIncrement()),
            uint(0),
            null,
            uint(60),
            null);

    TestStackRequest request = new TestStackRequest(header, uint(0), 1, new Variant(input));

    return client.sendRequest(request);
  }
  private void disconnect(ClientSecureChannel secureChannel, CompletableFuture<Unit> disconnected) {
    RequestHeader requestHeader =
        new RequestHeader(NodeId.NULL_VALUE, DateTime.now(), uint(0), uint(0), null, uint(0), null);

    secureChannel
        .getChannel()
        .pipeline()
        .addFirst(
            new ChannelInboundHandlerAdapter() {
              @Override
              public void channelInactive(ChannelHandlerContext ctx) throws Exception {
                logger.debug("channelInactive(), disconnect complete");
                disconnected.complete(Unit.VALUE);
              }
            });

    logger.debug("Sending CloseSecureChannelRequest...");
    CloseSecureChannelRequest request = new CloseSecureChannelRequest(requestHeader);
    secureChannel.getChannel().pipeline().fireUserEventTriggered(request);
  }