|
@@ -79,10 +79,10 @@ public class GroupNettyClient {
|
|
|
.handler(new ChannelInitializer<SocketChannel>() {
|
|
|
@Override
|
|
|
protected void initChannel(SocketChannel ch) throws Exception {
|
|
|
- ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 8, 0, 8));
|
|
|
- ch.pipeline().addLast(new LengthFieldPrepender(8));
|
|
|
+ ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
|
|
|
// 将分隔之后的字节数据转换为字符串
|
|
|
ch.pipeline().addLast(new StringDecoder());
|
|
|
+ ch.pipeline().addLast(new LengthFieldPrepender(4));
|
|
|
ch.pipeline().addLast(new StringEncoder());
|
|
|
// pipeline可以理解为所有handler的初始化容器
|
|
|
ch.pipeline().addLast(new GroupNettyClientHandler(groupNettyClient, alarmDefineService, alarmRecordRepository));// 添加自定义handler
|