MyByteToLoneDecoder2
package com.atguigu.netty.inboundhandlerandoutboundhandler;
import com.atguigu.netty.simple.NettyClientHandler;
import java.util.List;
public class MyByteToLoneDecoder2 extends ReplayingDecoder<Void>{
protected <CHannelHandlerContext> void decode
(CHannelHandlerContext ctx, NettyClientHandler.
ByteBuf in, List<Object> out)throws Exception{
System.out.println("MyByteToLongDecoder 被调用");
//因为 long 8个字节,需要判断有8个字节,才能读取一个long
if(in.readableBytes()>=8)
out.add(in.readLong());
}
}

浙公网安备 33010602011771号