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