public class Client {
Vertx vertx;
public Client(Vertx vx) {
vertx = vx;
}
public void sendHeartPackage(String host, int port, long timeout) {
CompletableFuture<HttpClientResponse> cf = new CompletableFuture<HttpClientResponse>();
TimeoutStream ts = vertx.periodicStream(2000);
ts.handler(handler -> {
vertx.createHttpClient().getNow(port, host, "is_alive?", response -> {
cf.complete(response);
});
vertx.setTimer(timeout, result -> {
if (cf.isDone() == false) {
ts.cancel();
System.out.println("connect fail!");
}
System.out.println("connect OK!");
});
});
}
}
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/6690b51b-2a06-4234-9408-dd4d9c50f7fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
it better to have some example !