private void BarsSubscribeTimerElapsed(object sender, ElapsedEventArgs e) { try { var subscribers = ClientsCollection.GetAll(); foreach (var subscriber in subscribers) { List <BarsSubscription> bars = new List <BarsSubscription>(); lock (subscriber.Subscriptions.Bars) { bars.AddRange(subscriber.Subscriptions.Bars); } foreach (var barOptions in bars) { var response = new BarsSubscribeResponse { ID = barOptions.ID, Symbol = barOptions.Symbol, Bars = new List <Bar> { DataProvider.GetBarUpdate(barOptions) } }; subscriber.SocketSession.Send(JsonSerializeHelper.Serialize(response)); } } } catch (Exception ex) { Logger.Error(ex); } }
private void QuotesSubscribeTimerElapsed(object sender, ElapsedEventArgs e) { try { var subscribers = ClientsCollection.GetAll(); foreach (var subscriber in subscribers) { List <string> q = new List <string>(); lock (subscriber.Subscriptions.Quotes) { q.AddRange(subscriber.Subscriptions.Quotes); } if (q.Count == 0) { continue; } var quotes = new List <Quote>(); foreach (var symbol in q) { quotes.Add(DataProvider.GetQuoteUpdate(symbol)); } if (quotes.Count > 0) { subscriber.SocketSession.Send(JsonSerializeHelper.Serialize(new QuotesSubscribeResponse { Quotes = quotes })); } } } catch (Exception ex) { Logger.Error(ex); } }