From 0efb002d79eda0b1ef539cf8a029f14b5395f83e Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 06 八月 2025 15:01:28 +0800
Subject: [PATCH] 合并代码

---
 MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyChannelMap.java |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyChannelMap.java b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyChannelMap.java
index 228c11d..a0dd469 100644
--- a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyChannelMap.java
+++ b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyChannelMap.java
@@ -26,7 +26,7 @@
 	 */
 	public static ChannelHandlerContext getData(String key) {
 		if(map==null){
-			map = new ConcurrentHashMap<String, ChannelHandlerContext>();
+			map = new HashMap<String, ChannelHandlerContext>();
 		}
 		return map.get(key);
 	}
@@ -78,6 +78,9 @@
 	 */
 	@SuppressWarnings("rawtypes")
 	public static synchronized void remove(ChannelHandlerContext value) {
+		if(null == value){
+			return;
+		}
 		Set<String> strings = map.keySet();
 		for(String key : strings){
 			ChannelHandlerContext channelHandlerContext = map.get(key);
@@ -91,6 +94,23 @@
 	}
 
 
+	public static synchronized void remove_(ChannelHandlerContext value) {
+		Set<String> strings = ctxMap.keySet();
+		for(String key : strings){
+			ChannelHandlerContext channelHandlerContext = ctxMap.get(key);
+			String s = channelHandlerContext.channel().remoteAddress().toString();
+			String s1 = value.channel().remoteAddress().toString();
+			if(s.equals(s1)){
+				channelHandlerContext.close();//关闭通道
+				ctxMap.remove(key);
+			}
+		}
+	}
+
+
+	public static synchronized void remove_(String key) {
+		ctxMap.remove(key);
+	}
 
 	
 	/**
@@ -113,4 +133,9 @@
 		map.put(key, value);
 	}
 
+
+
+	public static synchronized void update_(String key, ChannelHandlerContext value) {
+		ctxMap.put(key, value);
+	}
 }

--
Gitblit v1.7.1