if (obj instanceof ChannelBuffer) {
ChannelBuffer buffer = (ChannelBuffer) obj;
if (buffer.readableBytes() > 8) {
String version = buffer.toString(buffer.readerIndex(), 4, Charset.defaultCharset());
if (version.equals("RPC0")) {
Adler32 adler32 = new Adler32();
adler32.update(buffer.array(),
buffer.arrayOffset() + buffer.readerIndex(),
buffer.readableBytes() - 4);
buffer.markReaderIndex();
buffer.readerIndex(buffer.writerIndex() - 4);
int checksum = buffer.readInt();
if (checksum == (int)adler32.getValue()) {
buffer.resetReaderIndex();
RpcMessage message = RpcMessage.newBuilder().mergeFrom(
buffer.array(),
buffer.arrayOffset() + buffer.readerIndex() + 4,
buffer.readableBytes() - 8).build();