Examples of handler()


Examples of io.netty.bootstrap.Bootstrap.handler()

            Bootstrap b = new Bootstrap();
            b.group(workerGroup);
            b.channel(NioSocketChannel.class);
            b.option(ChannelOption.SO_KEEPALIVE, true);
            b.remoteAddress(HOST, PORT);
            b.handler(initializer);

            // Start the client.
            Channel channel = b.connect().syncUninterruptibly().channel();
            System.out.println("Connected to [" + HOST + ':' + PORT + ']');
View Full Code Here

Examples of io.netty.bootstrap.ServerBootstrap.handler()

        try {
            ServerBootstrap b = new ServerBootstrap();
            b.option(ChannelOption.SO_KEEPALIVE, true);
            b.group(bossGroup, workerGroup);
            b.channel(NioServerSocketChannel.class);
            b.handler(new LoggingHandler(LogLevel.INFO));
            b.childHandler(initializer);

            // Bind and start to accept incoming connections.
            ChannelFuture f = b.bind(port).sync();
            this.state = ServerState.RUNNING;
View Full Code Here

Examples of io.netty.channel.ChannelHandlerContext.handler()

  public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException {
    if (isSSL()) {
      final ChannelHandlerContext sslHandlerContext = channel.pipeline().context("ssl");
      assert sslHandlerContext != null;
      final SslHandler sslHandler = (SslHandler) sslHandlerContext.handler();
      return sslHandler.engine().getSession().getPeerCertificateChain();
    } else {
      return null;
    }
  }
View Full Code Here

Examples of io.vertx.core.TimeoutStream.handler()

  }

  @Test
  public void testTimerStreamCancellation() throws Exception {
    TimeoutStream timer = vertx.timerStream(10);
    timer.handler(l -> {
      fail();
    });
    timer.endHandler(v -> {
      testComplete();
    });
View Full Code Here

Examples of io.vertx.core.TimeoutStream.handler()

    stream.endHandler(v -> {
      assertTrue(vertx.context().isEventLoopContext());
      assertNull(stack.get());
      testComplete();
    });
    stream.handler(id -> {});
    await();
  }

  // This test does not pass
  @Test
View Full Code Here

Examples of io.vertx.core.TimeoutStream.handler()

    stream.endHandler(v -> {
      assertTrue(vertx.context().isEventLoopContext());
      assertNull(stack.get());
      testComplete();
    });
    stream.handler(id -> {
      stack.set(true);
      stream.cancel();
      stack.set(null);
    });
    await();
View Full Code Here

Examples of io.vertx.core.file.AsyncFile.handler()

    vertx.fileSystem().open(testDir + pathSep + fileName, new OpenOptions(), ar -> {
      if (ar.succeeded()) {
        AsyncFile rs = ar.result();
        rs.setReadPos(chunkSize * chunks / 2);
        Buffer buff = Buffer.buffer();
        rs.handler(buff::appendBuffer);
        rs.exceptionHandler(t -> fail(t.getMessage()));
        rs.endHandler(v -> {
          ar.result().close(ar2 -> {
            if (ar2.failed()) {
              fail(ar2.cause().getMessage());
View Full Code Here

Examples of io.vertx.core.http.HttpServerRequestStream.handler()

  @Test
  public void testCloseServerAsynchronously() {
    this.server = vertx.createHttpServer(new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTP_PORT));
    AtomicInteger done = new AtomicInteger();
    HttpServerRequestStream stream = server.requestStream();
    stream.handler(req -> {});
    ThreadLocal<Object> stack = new ThreadLocal<>();
    stack.set(true);
    stream.endHandler(v -> {
      assertTrue(vertx.context().isEventLoopContext());
      assertNull(stack.get());
View Full Code Here

Examples of io.vertx.core.http.ServerWebSocketStream.handler()

  @Test
  public void testWebsocketStreamCallbackAsynchronously() {
    this.server = vertx.createHttpServer(new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTP_PORT));
    AtomicInteger done = new AtomicInteger();
    ServerWebSocketStream stream = server.websocketStream();
    stream.handler(req -> { });
    ThreadLocal<Object> stack = new ThreadLocal<>();
    stack.set(true);
    stream.endHandler(v -> {
      assertTrue(vertx.context().isEventLoopContext());
      assertNull(stack.get());
View Full Code Here

Examples of io.vertx.core.net.NetSocket.handler()

      });
      server.listen(onSuccess(s -> {
        client.request(HttpMethod.CONNECT, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
          assertEquals(200, resp.statusCode());
          NetSocket socket = resp.netSocket();
          socket.handler(buff -> {
            received.appendBuffer(buff);
            if (received.length() == buffer.length()) {
              netServer.close();
              assertEquals(buffer, received);
              testComplete();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.