public virtual string UnSubscribeSymbol(string Symbol, List <string> Channels = null) { string Params = string.Empty; lock ( SubscribedSymbols ) { if (Channels == null) { // get/use all current Channels SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol); if (Rec != null) { Channels = Rec.Channels; } } if (Channels != null) { Params = FormatChannelParamsForSymbol(Symbol, Channels); if (!pgWebSocket.PGStatus.IsConnected) { QueueSubscribeData(Symbol, Params, Channels, false); } else { SendUnSubscribeMessage(Params); } } } return(Params); }
public virtual string SubscribeSymbol(string Symbol, List <string> Channels = null, bool CreateRec = true) { string Params = string.Empty; lock ( SubscribedSymbols ) { if (CreateRec) { SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol); if (Rec == null) { Rec = CreateSubscribeSymbolRec(Symbol, Channels); } Channels = Rec.Channels; Rec.ChannelsAdded = Channels; } Params = FormatChannelParamsForSymbol(Symbol, Channels); if (!pgWebSocket.PGStatus.IsConnected) { QueueSubscribeData(Symbol, Params, Channels, true, CreateRec); } else { SendSubscribeMessage(Params); } } return(Params); }
public void RemoveSymbol(string Symbol) { lock ( SubscribedSymbols ) { UnSubscribeSymbol(Symbol); SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol); if (Rec != null) { SubscribedSymbols.Remove(GetSymbolOnly(Symbol)); } } }
private void SetSubscribeSymbolRecsFlags(string Params, bool IsNew, bool ChannelsWereRemoved) { List <string> Symbols = Params.Split(',').ToList(); foreach (var Symbol in Symbols) { SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol); if (Rec != null) { Rec.IsNew = IsNew; Rec.ChannelsWereRemoved = ChannelsWereRemoved; } } }
public SubscribeSymbolRec CreateSubscribeSymbolRec(string Symbol, List <string> Channels = null) { Symbol = GetSymbolOnly(Symbol); SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol, true); if (Rec == null) { SubscribedSymbols[Symbol] = Rec = new SubscribeSymbolRec(Symbol) { // if Channels == null, use DefaultChannels for this Cluster Channels = Channels != null ? Channels : new List <string>(DefaultChannels) }; } return(Rec); }
private void VerifySubscribeSymbolRecsForParams(string Params, bool IsSubscribe) { List <string> Symbols = Params.Split(',').ToList(); foreach (var Symbol in Symbols) { SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol, true); if (Rec == null) { Rec = CreateSubscribeSymbolRec(Symbol); } // add Params to every record for event listeners to find/use Rec.Params = Params; if (IsSubscribe) { Rec.ChannelsAdded.Clear(); } else { Rec.ChannelsRemoved.Clear(); } foreach (string Channel in Symbols) { if (IsSubscribe) { Rec.ChannelsAdded.Add(GetChannelOnly(Channel)); } else { Rec.ChannelsRemoved.Add(GetChannelOnly(Channel)); } } Rec.Params = Params; } }
private void VerifyRemainingChannels(string Params) { List <string> Symbols = Params.Split(',').ToList(); foreach (var Symbol in Symbols) { SubscribeSymbolRec Rec = GetSubscribeSymbolRec(Symbol); if (Rec != null) { foreach (string Channel in Symbols) { Rec.Channels.Remove(GetChannelOnly(Channel)); } if (Rec.Channels.Count == 0) { SubscribedSymbols.Remove(Rec.Symbol); } // reset values Rec.ChannelsWereRemoved = false; } } }