public static void Main(string[] args)
        {
            try
            {
                LogAssembliesBeingUsed();
                Connect();

                Console.WriteLine("Listening for client account margin");
                var marginListener = _streamingClient.BuildClientAccountMarginListener();
                _listeners.Add(marginListener);
                marginListener.MessageReceived += (s, e) =>
                {
                    Console.WriteLine("ClientAccountMargin, equity: {0}", e.Data.NetEquity);
                };

                Console.WriteLine("Listening for quotes");
                var quotesListener = _streamingClient.BuildQuotesListener();
                _listeners.Add(quotesListener);
                quotesListener.MessageReceived += (s, e) =>
                {
                    Console.WriteLine("Quote approved at {0}", e.Data.ApprovalDateTimeUTC);
                };

                Console.WriteLine("Listening for prices");
                var priceListener = _streamingClient.BuildPricesListener(Convert.ToInt32(ConfigurationManager.AppSettings["MarketId"]));
                _listeners.Add(priceListener);
                priceListener.MessageReceived += (s, message) => {
                    Console.WriteLine("Price at {0:O} is {1}", message.Data.TickDate, message.Data.Price);
                };

                Console.WriteLine("Listening for 120 seconds - check the number of open connections");
                var gate = new ManualResetEvent(false);
                gate.WaitOne(TimeSpan.FromSeconds(120));
            }
            finally
            {
                Disconnect();
            }
        }
        /// <exception cref="OverflowException">The dictionary already contains the maximum number of elements, <see cref="F:System.Int32.MaxValue" />.</exception>
        /// <exception cref="NotSupportedException">Condition. </exception>
        public void HandleRequest(Request request)
        {
            switch (request.RequestType)
            {
            case "NEWS":
                if (!String.IsNullOrEmpty(request.Parameters))
                {
                    var listenerNewsHeadlines = _streamingClient.BuildNewsHeadlinesListener(request.UserName, request.SessionToken, request.Parameters);
                    var newsEventHandler      = new NewsEventHandler(listenerNewsHeadlines);

                    if (!_subscriptions.TryAdd(request, newsEventHandler))
                    {
                        _logger.Error("Can't subscribe to NEWS datafeed");
                    }
                }

                _logger.Error("Can't subscribe to NEWS datafeed. News category wasn't provided");
                break;

            case "PRICES":
                var splitted = request.Parameters.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                if (splitted.Any())
                {
                    var listenerPrices    = _streamingClient.BuildPricesListener(request.UserName, request.SessionToken, splitted);
                    var priceEventHandler = new PriceEventHandler(listenerPrices);

                    if (!_subscriptions.TryAdd(request, priceEventHandler))
                    {
                        _logger.Error("Can't subscribe to PRICES datafeed");
                    }
                }

                _logger.Error("Can't subscribe to PRICES datafeed. Market ids weren't provided.");
                break;

            case "QUOTES":
                var listenerQuotes    = _streamingClient.BuildQuotesListener(request.UserName, request.SessionToken);
                var quoteEventHandler = new QuoteEventHandler(listenerQuotes);

                if (!_subscriptions.TryAdd(request, quoteEventHandler))
                {
                    _logger.Error("Can't subscribe to QUOTES datafeed");
                }
                break;

            case "CLIENTACCOUNTMARGIN":
                var listenerClientAccountMargin     = _streamingClient.BuildClientAccountMarginListener(request.UserName, request.SessionToken);
                var clientAccountMarginEventHandler = new ClientAccountMarginEventHandler(listenerClientAccountMargin);

                if (!_subscriptions.TryAdd(request, clientAccountMarginEventHandler))
                {
                    _logger.Error("Can't subscribe to CLIENTACCOUNTMARGIN datafeed");
                }
                break;

            case "ORDERS":
                var listenerOrders    = _streamingClient.BuildOrdersListener(request.UserName, request.SessionToken);
                var orderEventHandler = new OrderEventHandler(listenerOrders);

                if (!_subscriptions.TryAdd(request, orderEventHandler))
                {
                    _logger.Error("Can't subscribe to ORDERS datafeed");
                }
                break;

            case "DEFAULTPRICES":
                if (!String.IsNullOrEmpty(request.Parameters))
                {
                    int accountOperatorId;
                    Int32.TryParse(request.Parameters, out accountOperatorId);

                    if (accountOperatorId != 0)
                    {
                        var listenerDefaultPrices = _streamingClient.BuildDefaultPricesListener(request.UserName, request.SessionToken, accountOperatorId);
                        var priceEventHandler     = new PriceEventHandler(listenerDefaultPrices);

                        if (!_subscriptions.TryAdd(request, priceEventHandler))
                        {
                            _logger.Error("Can't subscribe to DEFAULTPRICES datafeed");
                        }
                    }
                    _logger.Error("Can't subscribe to DEFAULTPRICES datafeed. Can't parse account operator Id.");
                }
                else
                {
                    _logger.Error("Can't subscribe to DEFAULTPRICES datafeed. Account operator Id wasn't provided.");
                }
                break;

            case "TRADEMARGIN":
                var listenerTradeMargin     = _streamingClient.BuildTradeMarginListener(request.UserName, request.SessionToken);
                var tradeMarginEventHandler = new TradeMarginEventHandler(listenerTradeMargin);

                if (!_subscriptions.TryAdd(request, tradeMarginEventHandler))
                {
                    _logger.Error("Can't subscribe to TRADEMARGIN datafeed");
                }
                break;

            case "TRADINGACCOUNTMARGIN":
                var listenerTradingAccountMargin     = _streamingClient.BuildTradingAccountMarginListener(request.UserName, request.SessionToken);
                var tradingAccountMarginEventHandler = new TradingAccountMarginEventHandler(listenerTradingAccountMargin);

                if (!_subscriptions.TryAdd(request, tradingAccountMarginEventHandler))
                {
                    _logger.Error("Can't subscribe to TRADINGACCOUNTMARGIN datafeed");
                }
                break;

            default:
                throw new NotSupportedException();
            }
        }