Package io.netty.buffer

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


            ByteBuf buffer = (ByteBuf) msg;
            byte[] bytes;
            int offset;
            int len;
            if (buffer.hasArray()) {
                bytes = buffer.array();
                offset = buffer.arrayOffset() + buffer.readerIndex();
                len = buffer.readableBytes();
            } else {
                bytes = readBytes(buffer);
                offset = 0;
View Full Code Here


            byte[] input = CBUtil.readRawBytes(frame.body);
            ByteBuf output = CBUtil.onHeapAllocator.buffer(Snappy.maxCompressedLength(input.length));

            try
            {
                int written = Snappy.compress(input, 0, input.length, output.array(), output.arrayOffset());
                output.writerIndex(written);
            }
            catch (final Throwable e)
            {
                output.release();
View Full Code Here

            ByteBuf output = CBUtil.onHeapAllocator.buffer(Snappy.uncompressedLength(input));

            try
            {
                int size = Snappy.uncompress(input, 0, input.length, output.array(), output.arrayOffset());
                output.writerIndex(size);
            }
            catch (final Throwable e)
            {
                output.release();
View Full Code Here

            byte[] input = CBUtil.readRawBytes(frame.body);

            int maxCompressedLength = compressor.maxCompressedLength(input.length);
            ByteBuf outputBuf = CBUtil.onHeapAllocator.buffer(INTEGER_BYTES + maxCompressedLength);

            byte[] output = outputBuf.array();
            int outputOffset = outputBuf.arrayOffset();

            output[outputOffset + 0] = (byte) (input.length >>> 24);
            output[outputOffset + 1] = (byte) (input.length >>> 16);
            output[outputOffset + 2] = (byte) (input.length >>>  8);
View Full Code Here

            ByteBuf output = CBUtil.onHeapAllocator.buffer(uncompressedLength);

            try
            {
                int read = decompressor.decompress(input, INTEGER_BYTES, output.array(), output.arrayOffset(), uncompressedLength);
                if (read != input.length - INTEGER_BYTES)
                    throw new IOException("Compressed lengths mismatch");

                output.writerIndex(uncompressedLength);
View Full Code Here

         ByteBuf buffer = (ByteBuf) msg;
         byte[] bytes;
         int offset;
         int len;
         if (buffer.hasArray()) {
             bytes = buffer.array();
             offset = buffer.arrayOffset() + buffer.readerIndex();
             len = buffer.readableBytes();
         } else {
             bytes = readBytes(buffer);
             offset = 0;
View Full Code Here

            int oldNextInIndex = z.next_in_index;
            int oldNextOutIndex = z.next_out_index;

            int maxOutputLength = (int) Math.ceil(z.next_in.length * 1.001) + 12;
            out = alloc.heapBuffer(maxOutputLength);
            z.next_out = out.array();
            z.next_out_index = out.arrayOffset() + out.writerIndex();
            z.avail_out = maxOutputLength;

            int resultCode;
            try {
View Full Code Here

  @Override
  public byte[] getBytes() {
    ByteBuf buf = Unpooled.buffer(8);
    buf.writeInt(tid.block);
    buf.writeShort(tid.offset);
    return buf.array();
  }

  @Override
  public int hashCode() {
    final int prime = 31;
View Full Code Here

            long c = req.data().readLong();
            ByteBuf input = Unpooled.buffer(16);
            input.writeInt(a);
            input.writeInt(b);
            input.writeLong(c);
            res.data().writeBytes(WebSocketUtil.md5(input.array()));
        } else {
            // Old Hixie 75 handshake getMethod with no challenge:
            res.headers().add(WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
            res.headers().add(WEBSOCKET_LOCATION, uri());
            String protocol = req.headers().get(WEBSOCKET_PROTOCOL);
View Full Code Here

        int packetSize = config().getReceivePacketSize();
        ByteBuf buffer = alloc().heapBuffer(packetSize);
        boolean free = true;

        try {
            tmpPacket.setData(buffer.array(), buffer.arrayOffset(), packetSize);
            socket.receive(tmpPacket);

            InetSocketAddress remoteAddr = (InetSocketAddress) tmpPacket.getSocketAddress();
            if (remoteAddr == null) {
                remoteAddr = remoteAddress();
View Full Code Here

TOP
Copyright © 2015 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.