Helius
2021-02-26 e5e3bc5b8f863ce8f1069a12350432ea8cfbf965
src/main/java/com/xcong/excoin/netty/common/ChannelManager.java
@@ -61,6 +61,12 @@
    }
    public static void putSymbolSubChannel(@NotBlank String symbol, @NotNull Channel channel, @NotBlank String type) {
        String t = "";
        if (type.contains("depth")) {
            String[] s = type.split("_");
            type = s[0];
            t = s[1];
        }
        switch (type) {
            case "kline" :
                ChannelGroup kline = KLINE_MAP.get(symbol);
@@ -71,12 +77,13 @@
                KLINE_MAP.put(symbol, kline);
                break;
            case "depth" :
                ChannelGroup depth = DEPTH_MAP.get(symbol);
                String key = symbol + "_" + t;
                ChannelGroup depth = DEPTH_MAP.get(key);
                if (depth == null) {
                    depth = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
                }
                depth.add(channel);
                DEPTH_MAP.put(symbol, depth);
                DEPTH_MAP.put(key, depth);
                break;
            case "trade" :
                ChannelGroup trade = TRADE_MAP.get(symbol);
@@ -92,6 +99,12 @@
    }
    public static void removeSymbolUnSubChannel(@NotBlank String symbol, @NotNull Channel channel, @NotBlank String type) {
        String t = "";
        if (type.contains("depth")) {
            String[] s = type.split("_");
            type = s[0];
            t = s[1];
        }
        switch (type) {
            case "kline" :
                ChannelGroup kline = KLINE_MAP.get(symbol);
@@ -102,12 +115,13 @@
                KLINE_MAP.put(symbol, kline);
                break;
            case "depth" :
                ChannelGroup depth = DEPTH_MAP.get(symbol);
                String key = symbol + "_" + t;
                ChannelGroup depth = DEPTH_MAP.get(key);
                if (depth == null) {
                    return;
                }
                depth.remove(channel);
                DEPTH_MAP.put(symbol, depth);
                DEPTH_MAP.put(key, depth);
                break;
            case "trade" :
                ChannelGroup trade = TRADE_MAP.get(symbol);