关闭TCP长链接任务
1、关闭TCP长连接需要知道目标的IP地址,获取ip地址并将ip地址传入接口中。
2、调用SocketClientManager.closeClient(host);关闭tcp根据host(IP地址)
/**
* 根据接口id 关闭定时任务
* @param itfsid 接口id
* @param host host
* @return map:code、msg
*/
public static Map<String, Object> closeByItfsuid(String itfsid, String host) {
Map<String, Object> resMap = new HashMap<>();
resMap.put("code", "200");
resMap.put("msg", "成功停止");
try{
// 关闭定时任务根据itfsid
ScheduledTasks.get().stopScheduled(itfsid);
if (StringUtils.isNotBlank(host)) {
// 关闭TCP根据host
SocketClientManager.closeClient(host);
}
} catch (Exception e){
resMap.put("code", "500");
resMap.put("msg", e.getMessage());
}
return resMap;
}
本文档来自—microbee-http 丨 软件开发框架平台
扫一扫