钟日健
2022-05-19 de31e91aa2f38a717f2d4640a3197580ec1807a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//package org.springblade.modules.webscoket;
//import io.netty.channel.Channel;
//import io.netty.channel.ChannelId;
//import io.netty.channel.group.ChannelGroup;
//import io.netty.channel.group.DefaultChannelGroup;
//import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
//import io.netty.util.concurrent.GlobalEventExecutor;
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//import java.util.concurrent.ConcurrentMap;
//
//public class ChannelSupervise {
//    private   static ChannelGroup GlobalGroup=new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
//    private  static ConcurrentMap<String, ChannelId> ChannelMap=new ConcurrentHashMap();
//    private  static Map<String, String> map = new HashMap<String, String>();;
//    public  static void addChannel(Channel channel, String name){
//        GlobalGroup.add(channel);
//        ChannelMap.put(channel.id().asShortText(),channel.id());
//        map.put(channel.id().asShortText(),name);
//    }
//    public static void removeChannel(Channel channel){
//        GlobalGroup.remove(channel);
//        ChannelMap.remove(channel.id().asShortText());
//        map.remove(channel.id().asShortText());
//    }
//    public static Channel findChannel(String id){
//        return GlobalGroup.find(ChannelMap.get(id));
//    }
//    public static String findName(String id){
//    return map.get(id);
//    }
//    public static void send2All(TextWebSocketFrame tws){
//        GlobalGroup.writeAndFlush(tws);
//    }
//
//}