| | |
| | | */ |
| | | public static ChannelHandlerContext getData(String key) { |
| | | if(map==null){ |
| | | map = new ConcurrentHashMap<String, ChannelHandlerContext>(); |
| | | map = new HashMap<String, ChannelHandlerContext>(); |
| | | } |
| | | return map.get(key); |
| | | } |
| | |
| | | */ |
| | | @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); |
| | |
| | | } |
| | | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | map.put(key, value); |
| | | } |
| | | |
| | | |
| | | |
| | | public static synchronized void update_(String key, ChannelHandlerContext value) { |
| | | ctxMap.put(key, value); |
| | | } |
| | | } |