/// <summary>Receiver for "RemoveSubList" message</summary>
 public void OnRemoveSubscriberList(object _package = null)
 {
     //Checks whether package is valid before casting
     if (_package != null)
     {
         MPac_SubscriberListRemoved package = (MPac_SubscriberListRemoved)_package;
         ClearRemovedSubscriptions(package);
     }
 }
Пример #2
0
        /// <summary>Removes subscriber list.</summary>
        public void RemoveSubscriberList(string _messageHeader, MPac_SubscriberListRemoved _package)
        {
            if (m_listReferences.ContainsKey(_messageHeader))
            {
                TriggerRemove(new MessageBuffer(_messageHeader, _package));

                int index = GetMessageIndex(_messageHeader);
                m_subscriberList.RemoveAt(index);

                RemoveReferences(_messageHeader);
            }
        }
        /// <summary>Removes relevant ActiveSubscription and triggers remove functions.</summary>
        private void ClearRemovedSubscriptions(MPac_SubscriberListRemoved _package)
        {
            //Checks whether MessageHeader's prefix is of interest
            string prefix = MessageHelper.GetPrefix(_package.MessageHeader);

            if (m_prefixesOfInterest.ContainsKey(prefix))
            {
                //Checks whether Interest matches existing ActiveSubscription
                foreach (Interest interest in m_prefixesOfInterest[prefix])
                {
                    ActiveSubscription subscription = GetActiveSubscription(interest.m_persistence,
                                                                            _package.MessageHeader, interest.m_messageFunction);

                    //If it exists, clears ActiveSubscription
                    if (subscription != null)
                    {
                        if (subscription.m_dynamicMessageHeader == _package.MessageHeader)
                        {
                            interest.m_removeFunction(_package);
                            ClearActiveSubscription(interest, _package.MessageHeader);
                        }
                    }
                }
            }

            //Checks whether Messageheader matches existing ActiveSubscription
            if (m_dynamicMessagesOfInterest.ContainsKey(_package.MessageHeader))
            {
                //If it exists, clears ActiveSubscription
                foreach (Interest interest in m_dynamicMessagesOfInterest[_package.MessageHeader])
                {
                    interest.m_removeFunction(_package);
                    ClearActiveSubscription(interest, _package.MessageHeader);
                }
            }
        }