public void RegisterAll() { _allProducts = true; _products = new List <IProductModel>(); if (_connection.State != HubConnectionState.Connected) { return; } var handleOptions = new ClientOptionsWs { AllProducts = true, MessageTypes = new List <StreamingMessageType> { StreamingMessageType.StockLastTrade } }; try { _connection.SendAsync("HandleStockProductsMessage", handleOptions).Wait(); } catch (Exception e) { _logger.LogError(e, "HandleStockProductsMessage"); } }
public void RegisterProducts(IList <IProductModel> products) { _products = products; _allProducts = false; if (_connection.State != HubConnectionState.Connected) { return; } var productsName = string.Join(", ", products.Select(p => p.Ticker)); _logger.LogInformation($"Registering products: {productsName}"); var stockProducts = products.Where(p => p.Type == SymbolType.Stock).ToList(); var handleOptions = new ClientOptionsWs { Products = stockProducts.Cast <StockProductModel>().ToList(), MessageTypes = new List <StreamingMessageType> { StreamingMessageType.StockLastTrade } }; _connection.SendAsync("HandleStockProductsMessage", handleOptions); }