Пример #1
0
        }//constructor

        //
        //
        #endregion//Constructors


        #region no Properties
        // *****************************************************************
        // ****                     Properties                          ****
        // *****************************************************************
        //
        //
        #endregion//Properties


        #region Public Request / Lookup Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        //
        // *****************************************************
        // ****             Request Instruments()           ****
        // *****************************************************
        /// <summary>
        /// Extends the MarketHub base class requests by allowing TT Users to
        /// request market information using only the TT InstrumentKey.
        /// </summary>
        /// <param name="key">Requests instrument details for TT InstrumentKey </param>
        /// <returns></returns>
        public bool RequestInstruments(InstrumentKey key)
        {
            MarketHubRequest request = GetRequest(MarketHubRequest.RequestType.RequestInstruments);

            request.Data.Add(key);
            return(this.HubEventEnqueue(request));
        }
Пример #2
0
        }//ProcessTTApiServiceChange()

        //
        //
        // *****************************************************************
        // ****             Process Hub Request Shutdown()              ****
        // *****************************************************************
        private void ProcessHubRequestShutdown(MarketHubRequest request)
        {
            // Dispose of TT subscription objects.
            foreach (ProductCatalogSubscription subscription in m_ProductCatalogSubscriptionList.Values)
            {
                subscription.Dispose();
            }
            m_ProductCatalogSubscriptionList.Clear();

            if (m_PriceListener != null)
            {
                m_PriceListener.Dispose();
            }
            base.Stop();
        }// ProcessHubRequestShutdown().
Пример #3
0
        private List <EventArgs> m_WorkList = new List <EventArgs>();                     // private workspace for HubEventHandler()
        //
        /// <summary>
        /// This is the master Hub responding method. From here we call specific processing methods,
        /// one for each type of event that we can process; some from user, some from exchange API.
        /// This is called by the hub thread.
        /// </summary>
        protected override void HubEventHandler(EventArgs[] eventArgList)
        {
            m_WorkList.Clear();
            foreach (EventArgs eventArg in eventArgList)
            {
                if (eventArg == null)
                {
                    continue;
                }
                try
                {
                    Type eventType = eventArg.GetType();
                    if (eventType == typeof(PriceListener.InstrumentsFoundEventArgs))
                    {
                        ProcessInstrumentsFound((PriceListener.InstrumentsFoundEventArgs)eventArg);     // PriceListener catalog of instruments updated
                    }
                    else if (eventType == typeof(Misty.Lib.BookHubs.MarketUpdateEventArgs))
                    {
                        m_WorkList.Add(eventArg);
                    }
                    else if (eventType == typeof(Misty.Lib.BookHubs.MarketStatusEventArgs))
                    {
                        m_WorkList.Add(eventArg);
                    }
                    else if (eventType == typeof(MarketCatalogUpdatedEventArgs))
                    {
                        ProcessMarketCatalogUpdate((MarketCatalogUpdatedEventArgs)eventArg);            // TT catalog of markets updated
                    }
                    else if (eventType == typeof(ProductCatalogUpdatedEventArgs))
                    {
                        ProcessProductCatalogUpdate((ProductCatalogUpdatedEventArgs)eventArg);          // TT catalog of products updated
                    }
                    else if (eventType == typeof(MarketHubRequest))
                    {
                        MarketHubRequest request = (MarketHubRequest)eventArg;                          // User requests
                        switch (request.Request)
                        {
                        case MarketHubRequest.RequestType.RequestServers:
                            // this is done automatically at start.
                            break;

                        case MarketHubRequest.RequestType.RequestProducts:
                            ProcessHubRequestProducts(request);
                            break;

                        case MarketHubRequest.RequestType.RequestInstruments:
                            ProcessHubRequestInstruments(request);
                            break;

                        case MarketHubRequest.RequestType.RequestInstrumentSubscription:
                            ProcessHubRequestInstrumentPrice(request);
                            break;

                        case MarketHubRequest.RequestType.RequestShutdown:
                            ProcessHubRequestShutdown(request);
                            break;

                        default:
                            Log.NewEntry(LogLevel.Warning, "HubEventHandler: Request not recognized. {0}", request.ToString());
                            break;
                        }//switch user request type
                    }
                    else if (eventType == typeof(FeedStatusChangedEventArgs))
                    {
                        ProcessFeedStatusChange((FeedStatusChangedEventArgs)eventArg);                      // TT feed status changed
                    }
                    else if (eventType == typeof(TTServices.TTApiService.ServiceStatusChangeEventArgs))
                    {
                        ProcessTTApiServiceChange((TTServices.TTApiService.ServiceStatusChangeEventArgs)eventArg);
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Warning, "HubEventHandler: Unknown event received: {0} ", eventArg.GetType().Name);
                    }
                }
                catch (Exception ex)
                {
                    Misty.Lib.Application.ExceptionCatcher.QueryUserTakeAction(ex, this, eventArg);
                }
            }//next eventArg in list
            if (m_WorkList.Count > 0)
            {
                base.ProcessBookEvents(m_WorkList);
            }
        }//HubEventHandler()