Example usage for io.vertx.core.net NetServer close

List of usage examples for io.vertx.core.net NetServer close

Introduction

In this page you can find the example usage for io.vertx.core.net NetServer close.

Prototype

void close(Handler<AsyncResult<Void>> completionHandler);

Source Link

Document

Like #close but supplying a handler that will be notified when close is complete.

Usage

From source file:examples.NetExamples.java

License:Open Source License

public void example9(NetServer server) {

    server.close(res -> {
        if (res.succeeded()) {
            System.out.println("Server is now closed");
        } else {//from  ww  w.j  a  v a 2  s.com
            System.out.println("close failed");
        }
    });
}

From source file:io.fabric8.msg.jnatsd.JNatsd.java

License:Apache License

public void stop() throws Exception {
    if (started.compareAndSet(true, false)) {
        pingPong.stop();// w ww .ja v a  2 s .c  om
        final CountDownLatch countDownLatch = new CountDownLatch(servers.size());

        for (JNatsClient client : clients) {
            client.close();
        }

        for (NetServer server : servers) {
            server.close(handler -> {
                countDownLatch.countDown();
            });
        }
        countDownLatch.await(5, TimeUnit.SECONDS);
        LOG.info("JNatsd shutdown");
    }
}