From f5f485b1b1919e6d312ed72628ed7c01d2f57def Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Wed, 19 Mar 2025 16:57:48 +0800
Subject: [PATCH] 增加图片回传完成通知解析

---
 ard-work/src/main/java/com/ard/tianyu/netty/handler/ClientHandler.java |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/tianyu/netty/handler/ClientHandler.java b/ard-work/src/main/java/com/ard/tianyu/netty/handler/ClientHandler.java
index 3fc7b5f..147f829 100644
--- a/ard-work/src/main/java/com/ard/tianyu/netty/handler/ClientHandler.java
+++ b/ard-work/src/main/java/com/ard/tianyu/netty/handler/ClientHandler.java
@@ -1,8 +1,8 @@
 package com.ard.tianyu.netty.handler;
 
+import com.ard.tianyu.domain.cache.TyTcpServerCache;
 import com.ard.tianyu.netty.TyNettyTcpClient;
-import com.ard.tianyu.netty.command.BaseCommand;
-import com.ard.tianyu.netty.command.HeartbeatCommand;
+import com.ard.tianyu.netty.command.BaseCmd;
 import com.ard.tianyu.service.ITyService;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
@@ -19,7 +19,7 @@
 @Component
 @Slf4j
 @ChannelHandler.Sharable
-public class ClientHandler extends SimpleChannelInboundHandler<BaseCommand> {
+public class ClientHandler extends SimpleChannelInboundHandler<BaseCmd> {
 
     @Resource
     private ITyService tyService;
@@ -28,11 +28,11 @@
     private TyNettyTcpClient tyNettyTcpClient;
 
     @Override
-    public void channelRead0(ChannelHandlerContext ctx, BaseCommand command) {
+    public void channelRead0(ChannelHandlerContext ctx, BaseCmd command) {
         InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress();
         String host = ipSocket.getHostString();
         int port = ipSocket.getPort();
-        tyService.processMessage(host + ":" + port, command);
+        tyService.processReplyMessage(host + ":" + port, command);
     }
 
     @Override
@@ -46,7 +46,7 @@
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
         log.error("发生异常: ", cause); // 使用日志记录异常
-        ctx.close();
+       // ctx.close();
     }
 
     @Override
@@ -56,9 +56,9 @@
             if (event.state() == IdleState.READER_IDLE) {
                 log.info("客户端读超时");
             } else if (event.state() == IdleState.WRITER_IDLE) {
-                log.info("写空闲发送⼼跳!");
-                HeartbeatCommand msg = new HeartbeatCommand(System.currentTimeMillis());
-                ctx.writeAndFlush(msg);
+              //  log.info("写空闲发送⼼跳!");
+               // HeartbeatCommand msg = new HeartbeatCommand(System.currentTimeMillis());
+                //ctx.writeAndFlush(msg);
             } else if (event.state() == IdleState.ALL_IDLE) {
                 log.info("客户端所有操作超时");
             }
@@ -71,11 +71,11 @@
         int port = ipSocket.getPort();
         String host = ipSocket.getHostString();
         log.error("与天宇服务{}:{}连接断开!", host, port);
-
+        TyTcpServerCache.putTcpServerCache(host + ":" + port, false);
         ctx.channel().eventLoop().schedule(() -> {
             log.error("天宇服务端链接不上,开始重连操作...");
             try {
-                tyNettyTcpClient.initOneConnection(host, port);
+                tyNettyTcpClient.initConnection(host, port);
             } catch (Exception e) {
                 log.error("天宇服务端连接异常: {}", e.getMessage());
             }

--
Gitblit v1.9.3