private void UnsubscribeSymbol(OKExSymbol symbol, OKExSubscriptionType type) { if (symbol.InstrumentType == OKExInstrumentType.Index) { return; } if (!this.subscriberCache.TryGetValue(symbol.OKExInstrumentId, out var okexSubscriber)) { return; } var channelArgs = new List <OKExChannelRequest>(); okexSubscriber.RemoveChannel(type); if (symbol.TryGetChannelName(type, out string channelName)) { channelArgs.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } if (!okexSubscriber.ContainsAnyMainSubscription()) { okexSubscriber.RemoveChannel(OKExSubscriptionType.Ticker); if (symbol.TryGetChannelName(OKExSubscriptionType.Ticker, out channelName)) { channelArgs.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } if (symbol.InstrumentType != OKExInstrumentType.Spot) { okexSubscriber.RemoveChannel(OKExSubscriptionType.OpenInterest); if (symbol.TryGetChannelName(OKExSubscriptionType.OpenInterest, out channelName)) { channelArgs.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } } this.subscriberCache.Remove(symbol.OKExInstrumentId); } if (channelArgs.Count > 0) { this.publicWebsocket.RemoveFromQueue(channelArgs.ToArray()); } }
private void SubscribeSymbol(OKExSymbol symbol, OKExSubscriptionType type) { if (symbol.InstrumentType == OKExInstrumentType.Index) { return; } if (!this.subscriberCache.TryGetValue(symbol.OKExInstrumentId, out var okexSubscriber)) { this.subscriberCache[symbol.OKExInstrumentId] = okexSubscriber = new OKExGeneralSubscriber(symbol); } var args = new List <OKExChannelRequest>(); if (okexSubscriber.SubscriptionCount == 0) { okexSubscriber.AddSubscription(OKExSubscriptionType.Ticker); if (symbol.TryGetChannelName(OKExSubscriptionType.Ticker, out string channelName)) { args.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } if (okexSubscriber.Symbol.InstrumentType != OKExInstrumentType.Spot) { okexSubscriber.AddSubscription(OKExSubscriptionType.OpenInterest); if (symbol.TryGetChannelName(OKExSubscriptionType.OpenInterest, out channelName)) { args.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } } } if (!okexSubscriber.ContainsSubscription(type)) { okexSubscriber.AddSubscription(type); if (symbol.TryGetChannelName(type, out string channelName)) { args.Add(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } if (args.Count > 0) { this.publicWebsocket.AddRequestToQueue(args.ToArray()); } } }
internal void UnsubscribeIndexPrice(OKExSymbol symbol) { if (symbol.InstrumentType != OKExInstrumentType.Index) { return; } if (this.indexSubscriberCache.TryGetValue(symbol.OKExInstrumentId, out var subscriber)) { subscriber.RemoveChannel(OKExSubscriptionType.Ticker); this.indexSubscriberCache.Remove(symbol.OKExInstrumentId); if (symbol.TryGetChannelName(OKExSubscriptionType.Ticker, out string channelName)) { this.publicWebsocket.RemoveFromQueue(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } } }
internal void SubscribeIndexPrice(OKExSymbol symbol) { if (symbol.InstrumentType != OKExInstrumentType.Index) { return; } if (!this.indexSubscriberCache.ContainsKey(symbol.OKExInstrumentId)) { var subscriber = new OKExIndexSubscriber(symbol); subscriber.AddSubscription(OKExSubscriptionType.Ticker); this.indexSubscriberCache[symbol.OKExInstrumentId] = subscriber; if (symbol.TryGetChannelName(OKExSubscriptionType.Ticker, out string channelName)) { this.publicWebsocket.AddRequestToQueue(new OKExChannelRequest() { ChannelName = channelName, InstrumentId = symbol.OKExInstrumentId }); } } }