同步获取响应数据

This commit is contained in:
Guoqs
2024-07-31 16:48:29 +08:00
parent a6d3cf3366
commit eed9a7bc2c
25 changed files with 590 additions and 276 deletions

View File

@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
@ChannelHandler.Sharable
@Slf4j
@Component
public class NettyServerHandler extends ChannelInboundHandlerAdapter {
public class NettyServerHandler extends SimpleChannelInboundHandler {
@Autowired
private YKCBusinessService ykcService;
@@ -66,7 +66,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
*/
@Override
public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
// log.info("加载客户端报文=== channelId:" + ctx.channel().id() + ", msg:" + msg);
log.info("加载客户端报文channelRead=== channelId:" + ctx.channel().id() + ", msg:" + message);
// 下面可以解析数据保存数据生成返回报文将需要返回报文写入write函数
byte[] msg = (byte[]) message;
@@ -109,6 +109,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
}
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
log.info("channelRead0=== channelId:" + ctx.channel().id() + ", msg:" + msg);
}
/**
* 有客户端终止连接服务器会触发此函数
*/