Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.readableBytes()


      writer.write(WebSocketServer.getJavascript());

      ByteBuf content = res.content().writeBytes(writer.toString().getBytes(CharsetUtil.UTF_8));

      res.headers().set(CONTENT_TYPE, "text/javascript; charset=UTF-8");
      setContentLength(res, content.readableBytes());
   }

   @Override
   public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
      cause.printStackTrace();
View Full Code Here


                        if (lengthAttribute.get() != null) {
                            length = lengthAttribute.get();
                        }

                        while (buffer.readableBytes() > 0) {
                            switch (state) {
                                case WAIT_FOR_FIRST_BYTE_LENGTH:
                                    length = (buffer.readByte() & 255) << 24;
                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                                    break;
View Full Code Here

            if (lengthAttribute.get() != null) {
                length = lengthAttribute.get();
            }

            while (buffer.readableBytes() > 0) {
                switch (state) {
                case WAIT_FOR_FIRST_BYTE_LENGTH:
                    length = (buffer.readByte() & 255) << 24;
                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                    break;
View Full Code Here

                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255);
                                    state = State.READING;

                                    if ((length == 0) && (buffer.readableBytes() == 0)) {
                                        ctx.writeAndFlush(new DatagramPacket(ACK.retain(1).resetReaderIndex(), message.sender()));
                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                                    }
                                    break;
View Full Code Here

                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                                    }
                                    break;

                                case READING:
                                    int remaining = buffer.readableBytes();

                                    if (length > remaining) {
                                        length -= remaining;
                                        buffer.skipBytes(remaining);
                                    } else {
View Full Code Here

                case WAIT_FOR_FOURTH_BYTE_LENGTH:
                    length += (buffer.readByte() & 255);
                    state = State.READING;

                    if ((length == 0) && (buffer.readableBytes() == 0)) {
                        ctx.writeAndFlush(ACK.retain(1).resetReaderIndex());
                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                    }

                    break;
View Full Code Here

                    }

                    break;

                case READING:
                    int remaining = buffer.readableBytes();

                    if (length > remaining) {
                        length -= remaining;
                        buffer.skipBytes(remaining);
                    } else {
View Full Code Here

                    }

                    @Override
                    public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
                        ByteBuf buf = (ByteBuf)message;
                        for(int i=0; i < buf.readableBytes();i++) {
                            counter.countDown();
                            if (counter.getCount() > 0) {
                                sendMessage(ctx, data);
                            } else {
                                ctx.channel().close();
View Full Code Here

      // Compose message header and payload
      headerBuf.writeInt(messageLength);
      CompositeByteBuf fullByteBuf = channel.alloc().compositeBuffer(2);
      fullByteBuf.addComponent(headerBuf);
      fullByteBuf.writerIndex(headerBuf.readableBytes());
      if (message != null) {
        fullByteBuf.addComponent(message);
        fullByteBuf.writerIndex(fullByteBuf.writerIndex() + message.readableBytes());
      }
View Full Code Here

        request.headers().set(HttpHeaders.Names.USER_AGENT, env().userAgent());
        if (msg instanceof InsertBucketRequest || msg instanceof UpdateBucketRequest) {
            request.headers().set(HttpHeaders.Names.ACCEPT, "*/*");
            request.headers().set(HttpHeaders.Names.CONTENT_TYPE, "application/x-www-form-urlencoded");
        }
        request.headers().set(HttpHeaders.Names.CONTENT_LENGTH, content.readableBytes());

        addAuth(ctx, request, msg.bucket(), msg.password());

        return request;
    }
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.