| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | 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); |