diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/EchoServerHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/EchoServerHandler.java index 17de54448..12960f617 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/EchoServerHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/EchoServerHandler.java @@ -27,5 +27,21 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter { ctx.write(msg); //刷新缓存区 ctx.flush(); + + // ByteBuf byteBuf = (ByteBuf) msg; + // ByteBuf byteBuf = Unpooled.copiedBuffer("680d01000004882300000001290100d510", StandardCharsets.UTF_8); + // // byteBuf.readBytes(bytes); + // YKCDataProtocol ykcDataProtocol = new YKCDataProtocol(new byte[]{}); + // + // // 获取帧类型 + // byte[] frameTypeBytes = ykcDataProtocol.getFrameType(); + // String frameType = YKCUtils.frameType2Str(frameTypeBytes); + // // 获取序列号域 + // int serialNumber = BytesUtil.bytesToIntLittle(ykcDataProtocol.getSerialNumber()); + // if (!CollectionUtils.containsAny(NettyServerHandler.notPrintFrameTypeList, frameType)) { + // log.info("【>>>>>平台响应消息>>>>>】channel:{}, 响应帧类型:{}, 响应帧名称:{}, 序列号域:{}, response:{}", + // ctx.channel().id(), frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber, + // BytesUtil.binary(ykcDataProtocol.getBytes(), 16)); + // } } } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/NettyServerHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/NettyServerHandler.java index 2c801c821..724c37983 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/NettyServerHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/server/yunkuaichong/NettyServerHandler.java @@ -8,6 +8,7 @@ import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.YKCUtils; import com.jsowell.netty.service.yunkuaichong.YKCBusinessService; +import com.jsowell.netty.service.yunkuaichong.impl.YKCBusinessServiceImpl; import io.netty.buffer.ByteBuf; import io.netty.channel.*; import io.netty.handler.timeout.IdleState; @@ -19,6 +20,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.net.InetSocketAddress; import java.util.List; import java.util.Objects; @@ -32,15 +34,17 @@ import java.util.concurrent.ConcurrentHashMap; @Component public class NettyServerHandler extends ChannelInboundHandlerAdapter { - @Autowired - private YKCBusinessService ykcService; + // @Resource + // private YKCBusinessService ykcService; /** * 管理一个全局map,保存连接进服务端的通道数量 */ private static final ConcurrentHashMap CHANNEL_MAP = new ConcurrentHashMap<>(); - private final List notPrintFrameTypeList = Lists.newArrayList("0x03"); // "0x03" + protected static final List notPrintFrameTypeList = Lists.newArrayList(); // "0x03" + + private final YKCBusinessService ykcService = new YKCBusinessServiceImpl(); /** * 有客户端连接服务器会触发此函数 @@ -150,7 +154,6 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { ByteBuf buffer = ctx.alloc().buffer().writeBytes(response); // this.channelWrite(channel.id(), buffer); super.channelRead(ctx, buffer); - if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) { // 应答帧类型 byte[] responseFrameTypeBytes = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(frameTypeBytes);