Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.readBytes()


            // ignore
            msg.readByte();
            int status = msg.readByte();
            int port = msg.readShort();
            byte[] addr = new byte[4];
            msg.readBytes(addr);

            ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));

            if (status == SocksProtocols.REQUEST_GRANTED) {
                ctx.getPipeline().remove(Socks4ClientBootstrap.FRAME_DECODER);
View Full Code Here


        synchronized (z) {
            try {
                // Configure input.
                ChannelBuffer compressed = (ChannelBuffer) msg;
                byte[] in = new byte[compressed.readableBytes()];
                compressed.readBytes(in);
                z.next_in = in;
                z.next_in_index = 0;
                z.avail_in = in.length;

                // Configure output.
View Full Code Here

        synchronized (z) {
            try {
                // Configure input.
                ChannelBuffer uncompressed = (ChannelBuffer) msg;
                byte[] in = new byte[uncompressed.readableBytes()];
                uncompressed.readBytes(in);
                z.next_in = in;
                z.next_in_index = 0;
                z.avail_in = in.length;

                // Configure output.
View Full Code Here

            return msg;
        }

        ChannelBuffer uncompressed = (ChannelBuffer) msg;
        byte[] in = new byte[uncompressed.readableBytes()];
        uncompressed.readBytes(in);

        int sizeEstimate = (int) Math.ceil(in.length * 1.001) + 12;
        ChannelBuffer compressed = ChannelBuffers.dynamicBuffer(sizeEstimate, channel.getConfig().getBufferFactory());

        synchronized (deflater) {
View Full Code Here

        @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
            synchronized (this) {
                buffer.readBytes(out, buffer.readableBytes());
                out.flush();
            }
        }

        @Override
View Full Code Here

            UnsafeByteArrayInputStream bis;
            try {
                do {
                    // read data into buffer.
                    int read = Math.min(readable, buf.length - limit);
                    input.readBytes(buf, limit, read);
                    limit += read;
                    readable -= read;
                    bis = new UnsafeByteArrayInputStream(buf, off, limit - off); // 不需要关闭
                    // decode object.
                    do {
View Full Code Here

    }

    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        logger.info("message receives in session handler...");
        ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
        Packet packet = Packet.parseFrom(buffer.readBytes(buffer.readableBytes()).array());
        ClientIdentity clientIdentity = null;
        try {
            switch (packet.getType()) {
                case SUBSCRIPTION:
                    Sub sub = Sub.parseFrom(packet.getBody());
View Full Code Here

                Assert.assertEquals(new String(expectedPayload, Charset.forName("UTF-8")), buf);
            } else {
                ChannelBuffer buf = frame.getBinaryData();
                byte[] data = new byte[buf.readableBytes()];
                buf.readBytes(data);

                Assert.assertArrayEquals(expectedPayload, data);
            }
            latch.setResult(null);
        } catch (Throwable e) {
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        final ChannelBuffer message = (ChannelBuffer) e.getMessage();
        final int size = message.readableBytes();
        final byte[] array = new byte[size];
        message.readBytes(array);
        this.nodeName = new String(array, Charsets.UTF_8);
        LOG.info("Channel {} is node {}.", ctx.getChannel(), nodeName);
        this.node = cluster.getNodeInfoByName(nodeName);
        if (node == null) {
            LOG.error("Node info for {} not found!", ctx.getChannel(), nodeName);
View Full Code Here

        byte data[];
        if (buf.hasArray()) {
            data = buf.array();
        } else {
            data = new byte[buf.readableBytes()];
            buf.readBytes(data);
        }
        lineHandler.onLine(session, data);
    }

}
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.