protected virtual SessionsRuntimeInformationMessage Receive(RequestSymbolsRuntimeInformationMessage message)
        {
            DataSourceStub.IImplementation implementation = Implementation;

            List <RuntimeDataSessionInformation> result = new List <RuntimeDataSessionInformation>();

            if (implementation != null && OperationalState == OperationalStateEnum.Operational)
            {
                foreach (Symbol symbol in message.Symbols)
                {
                    lock (this)
                    {
                        if (_symbolsRunningSessions.ContainsKey(symbol) && _symbolsRunningSessions[symbol] != null)
                        {
                            result.Add(_symbolsRunningSessions[symbol].SessionInformation);
                            continue;
                        }
                    }

                    // Failed to find in already existing, query the implementation to create us a new one.
                    RuntimeDataSessionInformation sessionInformation = implementation.GetSymbolSessionRuntimeInformation(symbol);
                    if (sessionInformation != null)
                    {
                        lock (this)
                        {
                            _symbolsRunningSessions[sessionInformation.Info.Symbol] = new CombinedDataSubscriptionInformation(sessionInformation);
                        }
                        result.Add(sessionInformation);
                    }
                }
            }

            return(new SessionsRuntimeInformationMessage(result,
                                                         implementation != null && OperationalState == OperationalStateEnum.Operational));
        }
        public CombinedDataSubscriptionInformation GetUnsafeSessionSubscriptions(DataSessionInfo session)
        {
            DataSourceStub.IImplementation implementation = Implementation;
            if (implementation == null)
            {
                return(null);
            }

            bool isSymbolRunningSession;

            lock (this)
            {
                isSymbolRunningSession = (_symbolsRunningSessions.ContainsKey(session.Symbol) == false);
            }

            if (isSymbolRunningSession)
            {
                SystemMonitor.OperationWarning("Received a request for unknow session, creating a new session.");
                // Make sure to leave the sessionInformation orderInfo request outside of locks.
                RuntimeDataSessionInformation sessionInformation = implementation.GetSymbolSessionRuntimeInformation(session.Symbol);
                lock (this)
                {
                    _symbolsRunningSessions.Add(sessionInformation.Info.Symbol, new CombinedDataSubscriptionInformation(sessionInformation));
                }
            }

            lock (this)
            {
                //if (_sessionsSubscriptions.ContainsKey(session) == false)
                //{
                //    _sessionsSubscriptions[session] = new CombinedDataSubscriptionInformation(session);
                //}

                return(_symbolsRunningSessions[session.Symbol]);
            }
        }