protected virtual DataSubscriptionResponseMessage Receive(DataSubscriptionRequestMessage message)
        {
            if (message.TransportInfo.OriginalSenderId.HasValue == false)
            {
                SystemMonitor.Error("Received a message with no original sender. Dropped.");
                return null;
            }

            DataSourceStub.IImplementation implementation = Implementation;
            if (message.SessionInfo.IsEmtpy)
            {// General (un)subscription requestMessage, not specific to a sessionInformation.

                if (message.Subscribe)
                {
                    SystemMonitor.OperationError("Unexpected combination of empty session and subscribe request, ignored.");
                }
                else
                {// Unsubscribe to each that has a orderInfo for this original sender.
                    lock (this)
                    {
                        foreach (CombinedDataSubscriptionInformation combined in _symbolsRunningSessions.Values)
                        {
                            if (combined.FullUnsubscribe(message.TransportInfo.OriginalSenderId.Value))
                            {// For every sessionInformation that has something

                                // Make sure to pass combined as parameter, otherwise the value is in foreach and chages before the thread starts.
                                GeneralHelper.FireAndForget(
                                    delegate(CombinedDataSubscriptionInformation combinedValue)
                                {
                                    if (implementation != null)
                                    {// First allow the implementation to unsubscribe since it needs the combined dataDelivery.
                                        implementation.SessionDataSubscriptionUpdate(combinedValue.SessionInformation.Info, message.Subscribe, message.Information);
                                    }
                                }, combined);
                            }
                        }
                    }
                }
            }
            else
            {
                if (_symbolsRunningSessions.ContainsKey(message.SessionInfo.Symbol) == false
                    || _symbolsRunningSessions[message.SessionInfo.Symbol].SessionInformation.Info.Equals(message.SessionInfo) == false)
                {
                    SystemMonitor.Warning("Subsribe request for non existing session.");
                    return new DataSubscriptionResponseMessage(message.SessionInfo, false);
                }

                CombinedDataSubscriptionInformation combined = GetUnsafeSessionSubscriptions(message.SessionInfo);
                if (combined != null)
                {
                    combined.HandleRequest(message.TransportInfo, message.Subscribe, message.Information);
                    if (implementation != null)
                    {
                        GeneralHelper.FireAndForget(delegate()
                        {
                            implementation.SessionDataSubscriptionUpdate(message.SessionInfo, message.Subscribe, message.Information);
                        });
                    }
                }
                else
                {
                    SystemMonitor.OperationError("Combined subscription info not found.");
                }
            }

            // Finalizing / responding section.
            if (message.RequestResponse)
            {
                return new DataSubscriptionResponseMessage(message.SessionInfo, true);
            }

            return null;
        }
        public void UnInitialize()
        {
            StatusSynchronizationEnabled = false;
            if (OperationalState == OperationalStateEnum.Operational)
            {
                DataSubscriptionRequestMessage request = new DataSubscriptionRequestMessage(DataSessionInfo.Empty, false, null);
                request.RequestResponce = false;
                SendResponding(SourceTransportInfo, request);
            }

            ChangeOperationalState(OperationalStateEnum.UnInitialized);
        }
        protected virtual DataSubscriptionResponseMessage Receive(DataSubscriptionRequestMessage message)
        {
            if (message.TransportInfo.OriginalSenderId.HasValue == false)
            {
                SystemMonitor.Error("Received a message with no original sender. Dropped.");
                return null;
            }

            if (message.SessionInfo.IsEmtpy)
            {// General (un)subscription requestMessage, not specific to a sessionInformation.

                if (message.Subscribe)
                {
                    SystemMonitor.OperationError("Unexpected combination of empty session and subscribe request, ignored.");
                }
                else
                {// Unsubscribe to each that has a orderInfo for this original sender.
                    lock (this)
                    {
                        foreach (CombinedDataSubscriptionInformation combined in _dataSessions.Values)
                        {
                            if (combined.FullUnsubscribe(message.TransportInfo.OriginalSenderId.Value) == false)
                            {
                                SystemMonitor.OperationError("Failed to unsubscribe [" + message.TransportInfo.OriginalSenderId.Value.Id.Name + "].");
                            }
                        }
                    }
                }
            }
            else
            {
                lock (this)
                {
                    if (_dataSessions.ContainsKey(message.SessionInfo.Symbol) == false
                        || _dataSessions[message.SessionInfo.Symbol].SessionInformation.Info.Equals(message.SessionInfo) == false)
                    {
                        SystemMonitor.Warning("Subsribe request for non existing session.");
                        return new DataSubscriptionResponseMessage(message.SessionInfo, false);
                    }

                    CombinedDataSubscriptionInformation combined = _dataSessions[message.SessionInfo.Symbol];
                    if (combined != null)
                    {
                        TracerHelper.Trace("Subscribing... " + message.TransportInfo.OriginalSenderId.Value.Id.Name);
                        combined.HandleRequest(message.TransportInfo, message.Subscribe, message.Information);
                    }
                    else
                    {
                        SystemMonitor.OperationError("Combined subscription info not found.");
                    }
                }
            }

            // Finalizing / responding section.
            if (message.RequestResponse)
            {
                return new DataSubscriptionResponseMessage(message.SessionInfo, true);
            }

            return null;
        }
        public bool SubscribeToData(DataSessionInfo session, bool subscribe, DataSubscriptionInfo info)
        {
            if (OperationalState != OperationalStateEnum.Operational)
            {
                return false;
            }

            DataSubscriptionRequestMessage request = new DataSubscriptionRequestMessage(session, subscribe, info);
            DataSessionResponceMessage responce = SendAndReceiveResponding<DataSessionResponceMessage>(SourceTransportInfo, request);

            return responce != null && responce.OperationResult;
        }