Package io.netty.buffer

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


            } else {
                ctx.fireExceptionCaught(new DecoderException(t));
            }
        }

        if (out.readableBytes() > oldOutSize) {
            ctx.fireInboundBufferUpdated();
        }

        ctx.fireChannelInactive();
    }
View Full Code Here


    @Override
    public void messageReceived(final ChannelHandlerContext ctx,
            final UdtMessage message) throws Exception {
        final ByteBuf byteBuf = message.data();
        meter.mark(byteBuf.readableBytes());
        final MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
        out.add(message.retain());
        ctx.flush();
    }
View Full Code Here

    protected void encode(ChannelHandlerContext ctx, WebSocketFrame msg, ByteBuf out) throws Exception {
        if (msg instanceof TextWebSocketFrame) {
            // Text frame
            ByteBuf data = msg.data();
            out.writeByte((byte) 0x00);
            out.writeBytes(data, data.readerIndex(), data.readableBytes());
            out.writeByte((byte) 0xFF);
        } else if (msg instanceof CloseWebSocketFrame) {
            // Close frame
            out.writeByte((byte) 0xFF);
            out.writeByte((byte) 0x00);
View Full Code Here

            out.writeByte((byte) 0xFF);
            out.writeByte((byte) 0x00);
        } else {
            // Binary frame
            ByteBuf data = msg.data();
            int dataLen = data.readableBytes();
            out.ensureWritable(dataLen + 5);

            // Encode type.
            out.writeByte((byte) 0x80);
View Full Code Here

        if ("/".equals(req.getUri())) {
            ByteBuf content = WebSocketServerIndexPage.getContent(getWebSocketLocation(req));
            FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, OK, content);

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

            sendHttpResponse(ctx, req, res);
            return;
        }
        if ("/favicon.ico".equals(req.getUri())) {
View Full Code Here

    @Override
    public void inboundBufferUpdated(final ChannelHandlerContext ctx) throws Exception {
        ByteBuf buf = ctx.inboundByteBuffer();
        long curtime = System.currentTimeMillis();
        long size = buf.readableBytes();

        if (trafficCounter != null) {
            trafficCounter.bytesRecvFlowControl(size);
            if (readLimit == 0) {
                // no action
View Full Code Here

    @Override
    public void messageReceived(final ChannelHandlerContext ctx,
            final UdtMessage message) throws Exception {
        final ByteBuf byteBuf = message.data();
        meter.mark(byteBuf.readableBytes());
        final MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
        out.add(message.retain());
        ctx.flush();
    }
View Full Code Here

                throw new IllegalStateException("unexpected message type: " + msg.getClass().getSimpleName());
            }

            HttpContent chunk = (HttpContent) msg;
            ByteBuf content = chunk.data();
            int contentLength = content.readableBytes();

            if (state == ST_CONTENT_NON_CHUNK) {
                if (contentLength > 0) {
                    out.writeBytes(content, content.readerIndex(), content.readableBytes());
                }
View Full Code Here

            ByteBuf content = chunk.data();
            int contentLength = content.readableBytes();

            if (state == ST_CONTENT_NON_CHUNK) {
                if (contentLength > 0) {
                    out.writeBytes(content, content.readerIndex(), content.readableBytes());
                }

                if (chunk instanceof LastHttpContent) {
                    state = ST_INIT;
                }
View Full Code Here

            if (fullHttpMessage == null) {
                return null;
            }

            ByteBuf content = fullHttpMessage.data();
            if (content.readableBytes() > maxContentLength - spdyDataFrame.data().readableBytes()) {
                messageMap.remove(streamID);
                throw new TooLongFrameException(
                        "HTTP content length exceeded " + maxContentLength + " bytes.");
            }
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.