Esempio n. 1
0
        /// <summary>
        /// Retrieve a value for an existing parameter, if it exists
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void getParam([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            res.Set(0, 1);
            res.Set(1, "getParam");

            String caller_id = parm[0].GetString();
            String topic     = parm[1].GetString();

            // value = new XmlRpcValue();
            XmlRpcValue value = handler.getParam(caller_id, topic);

            //value
            // String vi = v.getString();
            if (value == null)
            {
                res.Set(0, 0);
                res.Set(1, "Parameter " + topic + " is not set");
                value = new XmlRpcValue("");
            }
            res.Set(2, value);

            //XmlRpcValue parm2 = new XmlRpcValue(), result2 = new XmlRpcValue();
            //parm2.Set(0, this_node.Name);
            //parm2.Set(1, mapped_key);

            //bool ret = master.execute("getParam", parm2, ref result2, ref v, false);
        }
Esempio n. 2
0
        public void getParamNames([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            res.Set(0, 1);
            res.Set(1, "getParamNames");

            String        caller_id = parm[0].GetString();
            List <String> list      = handler.getParamNames(caller_id);

            XmlRpcValue response = new XmlRpcValue();
            int         index    = 0;

            foreach (String s in list)
            {
                response.Set(index++, s);
            }

            res.Set(2, response);


            //throw new Exception("NOT IMPLEMENTED YET!");
            //XmlRpcValue parm = new XmlRpcValue(), result = new XmlRpcValue(), payload = new XmlRpcValue();
            //parm.Set(0, this_node.Name);
            //parm.Set(1, mapped_key);
            //if (!master.execute("deleteParam", parm, ref result, ref payload, false))
            //    return false;
            //return true;
        }
Esempio n. 3
0
 public XMLRPCFunc tobind <A, B, C, D>(Func <A, B, C, D, XmlRpcValue> act)
 {
     return((IntPtr parms, IntPtr result) =>
     {
         XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);
         XmlRpcValue rtn = act(parm[0].Get <A>(), parm[1].Get <B>(), parm[2].Get <C>(), parm[3].Get <D>());
         res.Set(0, rtn[0]);
         res.Set(1, rtn[1]);
         res.Set(2, rtn[2]);
     });
 }
Esempio n. 4
0
        public void getPublicationsCallback([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result);

            res.Set(0, 1);
            res.Set(1, "publications");
            XmlRpcValue response = new XmlRpcValue();

            getPublications(ref response);
            res.Set(2, response);
        }
Esempio n. 5
0
 public XMLRPCFunc tobind(Func <XmlRpcValue> act)
 {
     return((IntPtr parms, IntPtr result) =>
     {
         XmlRpcValue res = XmlRpcValue.Create(ref result);
         XmlRpcValue rtn = act();
         res.Set(0, rtn[0]);
         res.Set(1, rtn[1]);
         res.Set(2, rtn[2]);
     });
 }
Esempio n. 6
0
        /// <summary>
        /// Check whether a parameter exists
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void hasParam([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            res.Set(0, 1);
            res.Set(1, "hasParam");

            String caller_id = parm[0].GetString();
            String topic     = parm[1].GetString();

            res.Set(2, handler.hasParam(caller_id, topic));
        }
Esempio n. 7
0
        public void getBusInfoCallback([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result);

            res.Set(0, 1);
            res.Set(1, "");
            XmlRpcValue response = new XmlRpcValue();
            IntPtr      resp     = response.instance;

            getBusInfo(resp);
            res.Set(2, response);
        }
Esempio n. 8
0
        /// <summary>
        /// Register a new subscriber
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void registerSubscriber([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String caller_id  = parm[0].GetString();
            String topic      = parm[1].GetString();
            String type       = parm[2].GetString();
            String caller_api = parm[3].GetString(); //hostname

            handler.registerSubscriber(caller_id, topic, type, caller_api);
            res.Set(0, 1);
            res.Set(1, "GOOD JOB!");
            res.Set(2, new XmlRpcValue(""));

            //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, ref result, ref payload, true))
            //    return false;
            //List<string> pub_uris = new List<string>();
            //for (int i = 0; i < payload.Size; i++)
            //{
            //    XmlRpcValue asshole = payload[i];
            //    string pubed = asshole.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;
        }
Esempio n. 9
0
        public void requestTopicCallback([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            result = res.instance;
            if (!requestTopic(parm[1].Get <string>(), parm[2], ref res))
            {
                const string last_error = "Unknown error";

                XmlRpcManager.Instance.responseInt(0, last_error, 0)(result);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Set a new parameter
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void setParam([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            res.Set(0, 1);
            res.Set(1, "setParam");

            String      caller_api = parm[0].GetString();
            String      topic      = parm[1].GetString();
            XmlRpcValue value      = parm[2];

            handler.setParam(caller_api, topic, value);
            res.Set(2, "parameter " + topic + " set");
        }
Esempio n. 11
0
        /// <summary>
        /// Returns list of all, publishers, subscribers, and services
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void getSystemState([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            res.Set(0, 1);
            res.Set(1, "getSystemState");
            List <List <List <String> > > systemstatelist = handler.getSystemState("");//parm.GetString()

            XmlRpcValue listoftypes = new XmlRpcValue();

            XmlRpcValue listofvalues = new XmlRpcValue();

            int index = 0;

            foreach (List <List <String> > types in systemstatelist) //publisher, subscriber, services
            {
                int         bullshitindex = 0;
                XmlRpcValue typelist;
                XmlRpcValue bullshit = new XmlRpcValue();
                if (types.Count > 0)
                {
                    foreach (List <String> l in types)
                    {
                        int typeindex = 0;
                        typelist = new XmlRpcValue();
                        //XmlRpcValue value = new XmlRpcValue();
                        typelist.Set(typeindex++, l[0]);
                        XmlRpcValue payload = new XmlRpcValue();
                        for (int i = 1; i < l.Count; i++)
                        {
                            payload.Set(i - 1, l[i]);
                        }

                        typelist.Set(typeindex++, payload);
                        //typelist.Set(typeindex++, value);
                        bullshit.Set(bullshitindex++, typelist);
                    }
                }
                else
                {
                    typelist = new XmlRpcValue();
                    bullshit.Set(bullshitindex++, typelist);
                }


                listoftypes.Set(index++, bullshit);
            }

            res.Set(2, listoftypes);
        }
Esempio n. 12
0
        public void lookupNode([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String topic     = parm[0].GetString();
            String caller_id = parm[1].GetString();
            String api       = handler.lookupNode(caller_id, topic);

            // if(api == "")
            //       res.Set(0, 0);
            // else
            res.Set(0, 1);
            res.Set(1, "lookupNode");
            res.Set(2, api);
        }
Esempio n. 13
0
        /// <summary>
        /// Unregister an existing publisher
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void unregisterPublisher([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String caller_id  = parm[0].GetString();
            String topic      = parm[1].GetString();
            String caller_api = parm[2].GetString();

            Console.WriteLine("UNPUBLISHING: " + caller_id + " : " + caller_api);

            int ret = handler.unregisterPublisher(caller_id, topic, caller_api);

            res.Set(0, ret);
            res.Set(1, "unregistered " + caller_id + "as provder of " + topic);
        }
Esempio n. 14
0
        /// <summary>
        /// Register a new publisher to a topic
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void registerPublisher([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String caller_id  = parm[0].GetString();
            String topic      = parm[1].GetString();
            String type       = parm[2].GetString();
            String caller_api = parm[3].GetString(); //hostname

            Console.WriteLine("PUBLISHING: " + caller_id + " : " + caller_api);

            handler.registerPublisher(caller_id, topic, type, caller_api);
            res.Set(0, 1);
            res.Set(1, "GOOD JOB!");
            res.Set(2, new XmlRpcValue(""));
        }
Esempio n. 15
0
        public void pubUpdateCallback([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue   parm = XmlRpcValue.Create(ref parms);
            List <string> pubs = new List <string>();

            for (int idx = 0; idx < parm[2].Size; idx++)
            {
                pubs.Add(parm[2][idx].Get <string>());
            }
            if (pubUpdate(parm[1].Get <string>(), pubs))
            {
                XmlRpcManager.Instance.responseInt(1, "", 0)(result);
            }
            else
            {
                EDB.WriteLine("Unknown Error");
                XmlRpcManager.Instance.responseInt(0, "Unknown Error or something", 0)(result);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Get a list of all published topics
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void getPublishedTopics([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue           res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);
            List <List <String> > publishedtopics = handler.getPublishedTopics("", "");

            res.Set(0, 1);
            res.Set(1, "current system state");

            XmlRpcValue listofvalues = new XmlRpcValue();
            int         index        = 0;

            foreach (List <String> l in publishedtopics)
            {
                XmlRpcValue value = new XmlRpcValue();
                value.Set(0, l[0]); //Topic Name
                value.Set(1, l[1]); // Topic type
                listofvalues.Set(index, value);
                index++;
            }
            res.Set(2, listofvalues);
        }
Esempio n. 17
0
        /// <summary>
        /// Returns list of all publications
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void getPublications([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result);

            res.Set(0, 1);                            //length
            res.Set(1, "publications");               //response too
            XmlRpcValue response = new XmlRpcValue(); //guts, new value here

            //response.Size = 0;
            List <List <String> > current = handler.getPublishedTopics("", "");

            for (int i = 0; i < current.Count; i += 2)
            {
                XmlRpcValue pub = new XmlRpcValue();
                pub.Set(0, current[0]);
                current.RemoveAt(0);
                pub.Set(1, current[0]);
                current.RemoveAt(0);
                response.Set(i, pub);
            }
            res.Set(2, response);
        }
Esempio n. 18
0
        /// <summary>
        /// Unregister an existing subscriber
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="result"></param>
        public void unregisterSubscriber([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String caller_id  = parm[0].GetString();
            String topic      = parm[1].GetString();
            String caller_api = parm[2].GetString();

            Console.WriteLine("UNSUBSCRIBING: " + caller_id + " : " + caller_api);

            int ret = handler.unregisterSubscriber(caller_id, topic, caller_api);

            res.Set(0, ret);
            res.Set(1, "unregistered " + caller_id + "as provder of " + topic);

            //throw new Exception("NOT IMPLEMENTED YET!");
            //XmlRpcValue args = new XmlRpcValue(this_node.Name, topic, XmlRpcManager.Instance.uri),
            //            result = new XmlRpcValue(),
            //            payload = new XmlRpcValue();
            //master.execute("unregisterSubscriber", args, ref result, ref payload, false);
            //return true;
        }
Esempio n. 19
0
        public void getTopicTypes([In][Out] IntPtr parms, [In][Out] IntPtr result)
        {
            XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);

            String topic = parm[0].GetString();

            String caller_id = parm[1].GetString();
            Dictionary <String, String> types = handler.getTopicTypes(topic);

            XmlRpcValue value = new XmlRpcValue();
            int         index = 0;

            foreach (KeyValuePair <String, String> pair in types)
            {
                XmlRpcValue payload = new XmlRpcValue();
                payload.Set(0, pair.Key);
                payload.Set(1, pair.Value);
                value.Set(index, payload);
            }

            res.Set(0, 1);
            res.Set(1, "getTopicTypes");
            res.Set(2, value);
        }
Esempio n. 20
0
 /// <summary>
 /// No clue.
 /// </summary>
 /// <param name="parms"></param>
 /// <param name="result"></param>
 public void requestTopic([In][Out] IntPtr parms, [In][Out] IntPtr result)
 {
     throw new Exception("NOT IMPLEMENTED YET!");
     XmlRpcValue res = XmlRpcValue.Create(ref result), parm = XmlRpcValue.Create(ref parms);
 }