首页>代码>Spring boot 整合netty实现Socket通信Client/Server心跳自动重连>/spring-boot-netty-server/src/main/java/com/ibest/core/netty/server/MessageDecoder.java
package com.ibest.core.netty.server;

import java.util.List;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

public class MessageDecoder extends ByteToMessageDecoder {

	@Override
	protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
		  int len = in.readableBytes();
		  byte[] bytes = new byte[len];
		  in.readBytes(bytes);
		  HeartBeatMessage  msg = new HeartBeatMessage();
		  msg.setHeartbeat(new String(bytes));
		  out.add(msg);
	}

}
最近下载更多
airongjun  LV1 2023年8月31日
huangpeng1  LV4 2023年3月13日
aixiao5213  LV1 2022年12月28日
xiaoyuer2  LV8 2022年11月22日
youwuzuichen  LV10 2022年10月28日
809204304@qq.com  LV13 2022年10月24日
格林小满  LV1 2022年10月10日
JustinXiao  LV1 2022年10月7日
adminandroot  LV1 2022年10月7日
hnfjj  LV7 2022年6月30日
最近浏览更多
微信网友_6708769316278272 2023年10月26日
暂无贡献等级
漫步的海星  LV4 2023年9月21日
airongjun  LV1 2023年8月31日
sunwu5212  LV6 2023年6月28日
海盗来了  LV20 2023年3月23日
huangpeng1  LV4 2023年3月13日
Uting  LV3 2023年2月21日
aixiao5213  LV1 2022年12月28日
shenmofeng11  LV1 2022年12月8日
zhaoxu123123  LV10 2022年12月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友