Beispiel #1
0
        public override Message Clone()
        {
            var clone = new LastMessage {
                IsError = IsError
            };

            CopyTo(clone);
            return(clone);
        }
Beispiel #2
0
        /// <inheritdoc />
        public void SendOutMessage(Message message)
        {
            LastMessage lastMsg = null;

            void TryRemoveSubscription(long id, bool isError)
            {
                lock (_subscriptions.SyncRoot)
                {
                    if (_subscriptions.Remove(id) && _subscriptions.Count == 0)
                    {
                        lastMsg = new LastMessage
                        {
                            LocalTime = StopDate,
                            IsError   = isError,
                            Adapter   = this,
                        };
                    }
                }
            }

            switch (message.Type)
            {
            case MessageTypes.MarketData:
            {
                var response = (MarketDataMessage)message;

                if (!response.IsOk())
                {
                    TryRemoveSubscription(response.OriginalTransactionId, true);
                }

                break;
            }

            case MessageTypes.MarketDataFinished:
            {
                TryRemoveSubscription(((MarketDataFinishedMessage)message).OriginalTransactionId, false);
                break;
            }
            }

            message.Adapter = this;

            RaiseNewOutMessage(message);

            if (lastMsg != null)
            {
                RaiseNewOutMessage(lastMsg);
            }
        }