ByteToMessageDecoder
package com.atguigu.netty.inboundhandlerandoutboundhandler;
import com.atguigu.netty.simple.NettyClientHandler;
import java.util.List;
/**
*@paramctxin 上下文对象
*
* @param入站的 ByteBuft
* @paramout List 集合,将解码后的数据传给下-个handler
* @throwsException
*
*
* */
public class ByteToMessageDecoder {
protected void decode(NettyClientHandler.ChannelHandlerContext ctx,
NettyClientHandler.ByteBuf in, List<Object> out)
throws Exception {
//因为 long 8个字节
if(in.readableBytes()>=8){
out.add(in.readLong());
}
}
}

浙公网安备 33010602011771号