@Override public void channelRead0(final ChannelHandlerContext ctx, final RPCMessage msg) throws IOException { switch (msg.getType()) { case RPC_BLOCK_REQUEST: handleBlockRequest(ctx, (RPCBlockRequest) msg); break; case RPC_BLOCK_WRITE_REQUEST: handleBlockWriteRequest(ctx, (RPCBlockWriteRequest) msg); break; default: RPCErrorResponse resp = new RPCErrorResponse(RPCResponse.Status.UNKNOWN_MESSAGE_ERROR); ctx.writeAndFlush(resp); throw new IllegalArgumentException( "No handler implementation for rpc msg type: " + msg.getType()); } }