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());
}
}
}
posted @ 2024-02-04 05:35  shenqiqingyu  阅读(19)  评论(0)    收藏  举报