Package io.netty.buffer

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


        ByteBuf frame = (ByteBuf) super.decode(ctx, in);
        if (frame == null) {
            return null;
        }
        int len = frame.readInt();
        byte type = frame.readByte();
        long msb = frame.readLong();
        long lsb = frame.readLong();
        long hash = frame.readLong();
        byte[] segment = new byte[len - 25];
        frame.getBytes(29, segment);
View Full Code Here


  // NB: Java does not support static methods in interfaces, so we must put this in a static class.
  public static class Decoder {
    /** Deserializes the 'type' byte followed by the message itself. */
    public static BlockTransferMessage fromByteArray(byte[] msg) {
      ByteBuf buf = Unpooled.wrappedBuffer(msg);
      byte type = buf.readByte();
      switch (type) {
        case 0: return OpenBlocks.decode(buf);
        case 1: return UploadBlock.decode(buf);
        case 2: return RegisterExecutor.decode(buf);
        case 3: return StreamHandle.decode(buf);
View Full Code Here

            }

            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;

                case WAIT_FOR_SECOND_BYTE_LENGTH:
                    length += (buffer.readByte() & 255) << 16;
View Full Code Here

                    length = (buffer.readByte() & 255) << 24;
                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                    break;

                case WAIT_FOR_SECOND_BYTE_LENGTH:
                    length += (buffer.readByte() & 255) << 16;
                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
                    break;

                case WAIT_FOR_THIRD_BYTE_LENGTH:
                    length += (buffer.readByte() & 255) << 8;
View Full Code Here

                    length += (buffer.readByte() & 255) << 16;
                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
                    break;

                case WAIT_FOR_THIRD_BYTE_LENGTH:
                    length += (buffer.readByte() & 255) << 8;
                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
                    break;

                case WAIT_FOR_FOURTH_BYTE_LENGTH:
                    length += (buffer.readByte() & 255);
View Full Code Here

                    length += (buffer.readByte() & 255) << 8;
                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
                    break;

                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;
View Full Code Here

                        }

                        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;

                                case WAIT_FOR_SECOND_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 16;
View Full Code Here

                                    length = (buffer.readByte() & 255) << 24;
                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                                    break;

                                case WAIT_FOR_SECOND_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 16;
                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
                                    break;

                                case WAIT_FOR_THIRD_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 8;
View Full Code Here

                                    length += (buffer.readByte() & 255) << 16;
                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
                                    break;

                                case WAIT_FOR_THIRD_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 8;
                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
                                    break;

                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255);
View Full Code Here

                                    length += (buffer.readByte() & 255) << 8;
                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
                                    break;

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