Esempio n. 1
0
        protected virtual void OnNewStockUpdated(StockInfo stockInfo)
        {
            StockLiveUpdateEventHandler handler = NewStockUpdated;

            if (handler == null)
            {
                return;
            }
            Console.WriteLine($"New stock: {stockInfo.Symbol}, {stockInfo.Price}");
            handler(this, new StockLiveUpdateEventArgs {
                StockInfo = stockInfo
            });
        }
Esempio n. 2
0
 public void Subscribe(string clientId, StockLiveUpdateEventHandler handler)
 {
     lock (ClientSubscriptions)
     {
         if (ClientSubscriptions.ContainsKey(clientId))
         {
             Console.WriteLine($"Existing client [{clientId}] subscribes to symbol [{Symbol}]");
             return;
         }
         Console.WriteLine($"New client [{clientId}] subscribes to symbol [{Symbol}]");
         ClientSubscriptions.Add(clientId, handler);
         NewStockUpdated += handler;
     }
 }