Package io.netty.channel

Examples of io.netty.channel.Channel.writeAndFlush()


                logger.log(Level.FINE, "sending "+System.identityHashCode(message)+" "+message);
            }
            // HACK to fix ordering of messages
            singleThread.execute(new Runnable() { @Override public void run() {
                try {
                    chc.writeAndFlush(message);
                }
                catch (Exception ex) {
                    logger.log(Level.WARNING,"Failed to send "+key+" "+message,ex);
                }
            }});
View Full Code Here


                return;
            }

            final MessageFrame messageFrame = new MessageFrame(allMessages);
            logger.debug("flushing [{}]", messageFrame);
            channel.writeAndFlush(messageFrame).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(final ChannelFuture future) throws Exception {
                    if (!future.isSuccess()) {
                        final SockJsSession sockJsSession = getSockJsSession();
                        for (String msg : allMessages) {
View Full Code Here

        @Override
        public void send(String message) {
            final Channel channel = sessionState.getSendingContext().channel();
            if (isWritable(channel)) {
                channel.writeAndFlush(new MessageFrame(message));
            } else {
                sessionState.storeMessage(message);
            }
        }
View Full Code Here

            if (isWritable(channel)) {
                final CloseFrame closeFrame = new CloseFrame(3000, "Go away!");
                if (logger.isDebugEnabled()) {
                    logger.debug("Writing {}", closeFrame);
                }
                channel.writeAndFlush(closeFrame).addListener(ChannelFutureListener.CLOSE);
            }
        }

        @Override
        public ChannelHandlerContext getContext() {
View Full Code Here

                        new DefaultCookie("another-cookie", "bar"))
        );

        // send request
        List<Entry<String, String>> entries = headers.entries();
        channel.writeAndFlush(request);

        // Wait for the server to close the connection.
        channel.closeFuture().sync();

        return entries;
View Full Code Here

            SocketAddress remoteAddr = server.getSocketAddress();
            ch.connect(remoteAddr).sync();
        }

        //ch.writeAndFlush(msg).sync();
        ch.writeAndFlush(msg); // send asynchronously in the background
        return true;
    }

    private void replaceGroupIDIfRequired() {
        if(groupID.startsWith(DUMMY_JOB_ID)) {
View Full Code Here

                if (line == null || "quit".equalsIgnoreCase(line)) {
                    break;
                }

                // Sends the received line to the server.
                lastWriteFuture = ch.writeAndFlush(line);
            }

            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                lastWriteFuture.awaitUninterruptibly();
View Full Code Here

            // we'll send the datagrams using a timer.
            TimerTask task = new TimerTask() {
                @Override
                public void run() {
                    try {
                        ch.writeAndFlush(
                            new DatagramPacket(Unpooled.copiedBuffer(UDPMetricSerialization.toBytes(nextMetrics(locator, rand.nextInt(20) + 1))), addr)
                        ).sync();
                    } catch (Exception ex) {
                        ex.printStackTrace(System.err);
                    }
View Full Code Here

      public void operationComplete(ChannelFuture future) throws Exception {
        if (future.isSuccess()) {
          Channel channel = future.channel();
          channel.pipeline().addLast(new RequestExecuteHandler(responseFuture));
          FullHttpRequest nettyRequest = createFullHttpRequest(headers);
          channel.writeAndFlush(nettyRequest);
        }
        else {
          responseFuture.setException(future.cause());
        }
      }
View Full Code Here

            HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "");
            request.headers().set(HttpHeaders.Names.HOST, HOST);
            request.headers().set(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);

            // Send the GET request.
            channel.writeAndFlush(request).sync();

            // Waits for the complete HTTP response
            httpResponseHandler.queue().take().sync();
            System.out.println("Finished SPDY HTTP GET");
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.