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());




}
}
posted @ 2024-02-04 05:36  shenqiqingyu  阅读(6)  评论(0)    收藏  举报