From e5e3bc5b8f863ce8f1069a12350432ea8cfbf965 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 26 Feb 2021 15:31:18 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/netty/common/ChannelManager.java | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java b/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java
index 3937137..e6f6336 100644
--- a/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java
+++ b/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);
--
Gitblit v1.9.1