| | |
| | | |
| | | import com.xcong.excoin.modules.okxNewPrice.celue.CaoZuoService; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.ExchangeInfoEnum; |
| | | import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService; |
| | | import com.xcong.excoin.rabbit.pricequeue.WebsocketPriceService; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListService; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private CaoZuoService caoZuoService; |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | @Autowired |
| | | private WangGeListService wangGeListService; |
| | | |
| | | // 存储所有OkxQuantWebSocketClient实例,key为账号类型名称 |
| | | private final Map<String, OkxQuantWebSocketClient> quantClientMap = new ConcurrentHashMap<>(); |
| | | |
| | | // 存储OkxNewPriceWebSocketClient实例 |
| | | private OkxNewPriceWebSocketClient newPriceClient; |
| | | private OkxKlineWebSocketClient klinePriceClient; |
| | | |
| | | |
| | | /** |
| | | * 初始化方法,在Spring Bean构造完成后执行 |
| | |
| | | |
| | | // 初始化价格WebSocket客户端 |
| | | try { |
| | | newPriceClient = new OkxNewPriceWebSocketClient(redisUtils, caoZuoService, this); |
| | | newPriceClient.init(); |
| | | klinePriceClient = new OkxKlineWebSocketClient(redisUtils, caoZuoService, this, wangGeListService); |
| | | klinePriceClient.init(); |
| | | log.info("已初始化OkxNewPriceWebSocketClient"); |
| | | } catch (Exception e) { |
| | | log.error("初始化OkxNewPriceWebSocketClient失败", e); |
| | |
| | | log.info("开始销毁OkxWebSocketClientManager"); |
| | | |
| | | // 关闭价格WebSocket客户端 |
| | | if (newPriceClient != null) { |
| | | if (klinePriceClient != null) { |
| | | try { |
| | | newPriceClient.destroy(); |
| | | klinePriceClient.destroy(); |
| | | log.info("已销毁OkxNewPriceWebSocketClient"); |
| | | } catch (Exception e) { |
| | | log.error("销毁OkxNewPriceWebSocketClient失败", e); |
| | |
| | | * 获取OkxNewPriceWebSocketClient实例 |
| | | * @return 价格WebSocket客户端实例 |
| | | */ |
| | | public OkxNewPriceWebSocketClient getNewPriceClient() { |
| | | return newPriceClient; |
| | | public OkxKlineWebSocketClient getKlineWebSocketClient() { |
| | | return klinePriceClient; |
| | | } |
| | | } |