Beispiel #1
0
        public bool pubUpdate(string topic, List <string> pubs)
        {
#if DEBUG
            EDB.WriteLine("TopicManager is updating publishers for " + topic);
#endif
            Subscription sub = null;
            lock (subs_mutex)
            {
                if (shutting_down)
                {
                    return(false);
                }
                foreach (Subscription s in subscriptions)
                {
                    if (s.name != topic || s.IsDropped)
                    {
                        continue;
                    }
                    sub = s;
                    break;
                }
            }
            if (sub != null)
            {
                return(sub.pubUpdate(pubs));
            }
            EDB.WriteLine("got a request for updating publishers of topic " + topic +
                          ", but I don't have any subscribers to that topic.");
            return(false);
        }
Beispiel #2
0
        public bool registerSubscriber(Subscription s, string datatype)
        {
            string uri = XmlRpcManager.Instance.uri;

            XmlRpcValue args    = new XmlRpcValue(this_node.Name, s.name, datatype, uri);
            XmlRpcValue result  = new XmlRpcValue();
            XmlRpcValue payload = new XmlRpcValue();

            if (!master.execute("registerSubscriber", args, result, payload, true))
            {
                return(false);
            }
            List <string> pub_uris = new List <string>();

            for (int i = 0; i < payload.Size; i++)
            {
                XmlRpcValue load  = payload[i];
                string      pubed = load.Get <string>();
                if (pubed != uri && !pub_uris.Contains(pubed))
                {
                    pub_uris.Add(pubed);
                }
            }
            bool        self_subscribed = false;
            Publication pub             = null;
            string      sub_md5sum      = s.md5sum;

            lock (advertised_topics_mutex)
            {
                foreach (Publication p in advertised_topics)
                {
                    pub = p;
                    string pub_md5sum = pub.Md5sum;
                    if (pub.Name == s.name && md5sumsMatch(pub_md5sum, sub_md5sum) && !pub.Dropped)
                    {
                        self_subscribed = true;
                        break;
                    }
                }
            }

            s.pubUpdate(pub_uris);
            if (self_subscribed)
            {
                s.addLocalConnection(pub);
            }
            return(true);
        }