예제 #1
0
  private void sayHello() {
    if (_helloPrx == null) {
      return;
    }

    int delay = _delaySlider.getValue();
    try {
      if (!_deliveryMode.isBatch()) {
        _status.setText("Sending request");
        final DeliveryMode mode = _deliveryMode;
        java.util.concurrent.CompletableFuture<Void> f = _helloPrx.sayHelloAsync(delay);
        final Holder<Boolean> response = new Holder<Boolean>(false);
        f.whenComplete(
            (result, ex) -> {
              if (ex == null) {
                assert (!response.value);
                response.value = true;
                _status.setText("Ready");
              } else {
                assert (!response.value);
                response.value = true;
                handleException(ex);
              }
            });
        com.zeroc.Ice.Util.getInvocationFuture(f)
            .whenSent(
                (ss, ex) -> {
                  if (ex == null) {
                    if (mode.isOneway()) {
                      _status.setText("Ready");
                    } else if (!response.value) {
                      _status.setText("Waiting for response");
                    }
                  }
                });
      } else {
        _flush.setEnabled(true);
        _helloPrx.sayHello(delay);
        _status.setText("Queued sayHello request");
      }
    } catch (com.zeroc.Ice.LocalException ex) {
      handleException(ex);
    }
  }