断开连接取消定时任务
This commit is contained in:
@@ -3,6 +3,7 @@ package com.tongran.agent.client.netty.handler;
|
||||
import com.tongran.agent.client.core.config.GlobalConfig;
|
||||
import com.tongran.agent.client.core.session.SessionManager;
|
||||
import com.tongran.agent.client.scheduler.service.AppInitializer;
|
||||
import com.tongran.agent.client.service.AgentService;
|
||||
import com.tongran.agent.client.utils.AssertLog;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -26,6 +27,9 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private final SessionManager sessionManager;
|
||||
|
||||
@Resource
|
||||
private AgentService agentService;
|
||||
|
||||
public TCPListenHandler() {
|
||||
this.sessionManager = SessionManager.getInstance();
|
||||
}
|
||||
@@ -41,6 +45,7 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
||||
sessionManager.remove(ctx.channel());
|
||||
try {
|
||||
GlobalConfig.isCollect = false;
|
||||
agentService.cancelCollect();
|
||||
appInitializer.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -51,6 +56,7 @@ public class TCPListenHandler extends ChannelInboundHandlerAdapter {
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
|
||||
if (e instanceof IOException) {
|
||||
AssertLog.info("<<<<<<[终端断开连接]{} {}", sessionManager.client(ctx), e.getMessage());
|
||||
agentService.cancelCollect();
|
||||
} else {
|
||||
AssertLog.info(">>>>>>[消息处理异常]" + sessionManager.client(ctx), e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user