コード例 #1
0
        private void ProcessInPortfolioMessage(PortfolioMessage message)
        {
            var sendIn = false;
            var pfName = message.PortfolioName;

            SubscriptionInfo <PortfolioMessage> info;

            lock (_sync)
            {
                PortfolioMessage clone = null;
                info = _pfSubscribers.TryGetValue(pfName) ?? new SubscriptionInfo <PortfolioMessage>(clone = (PortfolioMessage)message.Clone());

                var subscribersCount = info.Subscribers;

                if (message.IsSubscribe)
                {
                    subscribersCount++;
                    sendIn = subscribersCount == 1;
                }
                else
                {
                    if (subscribersCount > 0)
                    {
                        subscribersCount--;
                        sendIn = subscribersCount == 0;
                    }
                    //else
                    //	sendOutMsg = NonExist(message);
                }

                info.Subscriptions.Add(clone ?? (PortfolioMessage)message.Clone());

                if (subscribersCount > 0)
                {
                    info.Subscribers       = subscribersCount;
                    _pfSubscribers[pfName] = info;
                }
                else
                {
                    _pfSubscribers.Remove(pfName);
                }
            }

            if (sendIn)
            {
                if (!message.IsSubscribe && message.OriginalTransactionId == 0)
                {
                    message.OriginalTransactionId = info.Message.TransactionId;
                }

                base.SendInMessage(message);
            }
        }
コード例 #2
0
        private void ProcessInPortfolioMessage(PortfolioMessage message)
        {
            var sendIn = false;
            var pfName = message.PortfolioName;

            RefPair <PortfolioMessage, int> pair;

            lock (_sync)
            {
                pair = _pfSubscribers.TryGetValue(pfName) ?? RefTuple.Create((PortfolioMessage)message.Clone(), 0);
                var subscribersCount = pair.Second;

                if (message.IsSubscribe)
                {
                    subscribersCount++;
                    sendIn = subscribersCount == 1;
                }
                else
                {
                    if (subscribersCount > 0)
                    {
                        subscribersCount--;
                        sendIn = subscribersCount == 0;
                    }
                    //else
                    //	sendOutMsg = NonExist(message);
                }

                if (subscribersCount > 0)
                {
                    pair.Second            = subscribersCount;
                    _pfSubscribers[pfName] = pair;
                }
                else
                {
                    _pfSubscribers.Remove(pfName);
                }
            }

            if (sendIn)
            {
                if (!message.IsSubscribe && message.OriginalTransactionId == 0)
                {
                    message.OriginalTransactionId = pair.First.TransactionId;
                }

                base.SendInMessage(message);
            }
        }