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;
case READING:
int remaining = buffer.readableBytes();
if (length > remaining) {
length -= remaining;
buffer.skipBytes(remaining);
} else {
buffer.skipBytes(length);
ctx.writeAndFlush(new DatagramPacket(ACK.retain(1).resetReaderIndex(), message.sender()));
state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
length = 0;
}
}
}