From 441d2fb39b873addb20cdff24a4122c443e5cf22 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Wed, 18 Dec 2024 09:13:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detection/service/impl/PreDetectionServiceImpl.java | 4 ++-- .../njcn/gather/detection/util/socket/cilent/NettyClient.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index d4322eb0..91e0aaa0 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -105,7 +105,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { msg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); msg.setData(JSON.toJSONString(sourceParam)); String s = userPageId + "_Source"; - NettyClient.socketClient(ip, port, new NettySourceClientHandler(s, sourceResponseService)); + NettyClient.socketClient(ip, port,userPageId, new NettySourceClientHandler(s, sourceResponseService)); SocketManager.sendMsg(s,JSON.toJSONString(msg)); @@ -136,7 +136,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { String ddId = param.getUserPageId(); Channel channel = SocketManager.getChannelByUserId(ddId); if( channel== null || !channel.isActive()){ - NettyClient.socketClient(ip, port,new NettySourceClientHandler(ddId, sourceResponseService)); + NettyClient.socketClient(ip, port,param.getUserPageId(),new NettySourceClientHandler(ddId, sourceResponseService)); } SocketManager.sendMsg(ddId,"start\n"); } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java index 8bce53d8..a28e0ea9 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.detection.util.socket.SocketManager; +import com.njcn.gather.detection.util.socket.WebServiceManager; import io.netty.bootstrap.Bootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; @@ -36,7 +37,7 @@ import java.util.concurrent.TimeUnit; public class NettyClient { - public static void socketClient(String ip, Integer port,SimpleChannelInboundHandler handler) { + public static void socketClient(String ip, Integer port,String userPageId,SimpleChannelInboundHandler handler) { NioEventLoopGroup group = new NioEventLoopGroup(); Bootstrap bootstrap = new Bootstrap(); try { @@ -69,6 +70,7 @@ public class NettyClient { group.shutdownGracefully(); //TODO 通知页面 + }finally { System.out.println("进入clientSocket最后步骤---------------------"); }