/** * 解码类继承 CumulativeProtocolDecoder 类 */ public class Decoder extends CumulativeProtocolDecoder { ...... @Override protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { //读取当前 IoBuffer 中已接收到的数据,判断是否得到了完整的数据包 if( 得到了可以解析的完整的数据包 ){ ...... return true; //通知父类的 decode 方法,当前接收并读取的数据已处理 }else{ in.rewind(); return false; //通知父类的 decode 方法,当前数据不完整,放弃本次读取,下个数据包到来时再做处理 } } ...... }
解决了问题,赞