Example #1
0
 public void unsubscribe(UnsubscribeMessage msg)
 {
     log(string.Format("[Unsubscribe] Received event '{0}'", msg));
     //if (isDuplicate(msg)) return;
     // should we have FIFO order here?
     lock (_topicSubscribers)
     {
         if (_topicSubscribers.ContainsKey(msg.topic))
         {
             _topicSubscribers[msg.topic].Remove(msg.uri);
             if (_topicSubscribers[msg.topic].Count == 0)
             {
                 _topicSubscribers.Remove(msg.topic);
             }
         }
     }
     PropagatedUnsubscribeMessage pmsg = new PropagatedUnsubscribeMessage(msg, _site);
     // propagate unsubscribe only to parent, taking advantage of tree strucure
     lock (_parentSiteLock)
     {
         if (_parentSite != null)
         {
             foreach (Broker b in _parentSite.brokers)
             {
                 log(string.Format("[Unsubscribe] senting '{0}' to parent site '{1}'", pmsg, _parentSite.name));
                 // TODO assyncronous
                 b.propagateUnsubscribe(pmsg);
             }
         }
     }
 }
Example #2
0
 public void propagateUnsubscribe(PropagatedUnsubscribeMessage msg)
 {
     log(string.Format("[propagateUnsubscribe] Received event '{0}'", msg));
     // TODO deal with duplicate messages. using which seqnum?...
     lock (_topicSites)
     {
         if (_topicSites.ContainsKey(msg.topic))
         {
             _topicSites[msg.topic].Remove(msg.interested_site);
             if (_topicSites[msg.topic].Count == 0)
             {
                 _topicSites.Remove(msg.topic);
             }
         }
     }
     msg.interested_site = _site;
     lock (_parentSiteLock)
     {
         if (_parentSite != null)
         {
             foreach (var b in _parentSite.brokers)
             {
                 log(string.Format("[subscribe] senting '{0}' to parent site '{1}'", msg, _parentSite.name));
                 //TODO assync
                 b.propagateSubscribe(msg);
             }
         }
     }
 }