/// <summary> /// Fired when a parameter gets updated /// </summary> /// <param name="parm">Name of parameter</param> /// <param name="result">New value of parameter</param> public static void paramUpdateCallback(IntPtr parm, IntPtr result) { XmlRpcValue val = XmlRpcValue.LookUp(parm); val.Set(0, 1); val.Set(1, ""); val.Set(2, 0); update(XmlRpcValue.LookUp(parm)[1].Get <string>(), XmlRpcValue.LookUp(parm)[2]); }
public Action <IntPtr> responseBool(int code, string msg, bool response) { return(p => { XmlRpcValue v = XmlRpcValue.LookUp(p); v.Set(0, code); v.Set(1, msg); v.Set(2, response); }); }
public Action <IntPtr> responseStr(IntPtr target, int code, string msg, string response) { return(p => { XmlRpcValue v = XmlRpcValue.LookUp(p); v.Set(0, code); v.Set(1, msg); v.Set(2, response); }); }
/// <summary> /// This is called when rosnode kill is invoked, or something /// </summary> /// <param name="p"> pointer to unmanaged XmlRpcValue containing params </param> /// <param name="r"> pointer to unmanaged XmlRpcValue that will contain return value </param> private static void shutdownCallback(IntPtr p, IntPtr r) { XmlRpcValue parms = XmlRpcValue.LookUp(p); int num_params = 0; if (parms.Type == TypeEnum.TypeArray) { num_params = parms.Size; } if (num_params > 1) { string reason = parms[1].Get <string>(); EDB.WriteLine("Shutdown request received."); EDB.WriteLine("Reason given for shutdown: [" + reason + "]"); shutdown(); } XmlRpcManager.Instance.responseInt(1, "", 0)(r); }
public void getBusInfo(IntPtr i) { XmlRpcValue info = XmlRpcValue.LookUp(i); info.Size = 0; lock (advertised_topics_mutex) { foreach (Publication t in advertised_topics) { t.getInfo(info); } } lock (subs_mutex) { foreach (Subscription t in subscriptions) { t.getInfo(info); } } }
public void pendingConnectionDone(PendingConnection conn, IntPtr res) { XmlRpcValue result = XmlRpcValue.LookUp(res); lock (shutdown_mutex) { if (shutting_down || _dropped) { return; } } XmlRpcValue proto = new XmlRpcValue(); if (!XmlRpcManager.Instance.validateXmlrpcResponse("requestTopic", result, ref proto)) { conn.failures++; EDB.WriteLine("Negotiating for " + conn.parent.name + " has failed " + conn.failures + " times"); return; } lock (pending_connections_mutex) { pending_connections.Remove(conn); } string peer_host = conn.client.Host; int peer_port = conn.client.Port; string xmlrpc_uri = "http://" + peer_host + ":" + peer_port + "/"; if (proto.Size == 0) { #if DEBUG EDB.WriteLine("Couldn't agree on any common protocols with [" + xmlrpc_uri + "] for topic [" + name + "]"); #endif return; } if (proto.Type != TypeEnum.TypeArray) { EDB.WriteLine("Available protocol info returned from " + xmlrpc_uri + " is not a list."); return; } string proto_name = proto[0].Get <string>(); if (proto_name == "UDPROS") { EDB.WriteLine("OWNED! Only tcpros is supported right now."); } else if (proto_name == "TCPROS") { if (proto.Size != 3 || proto[1].Type != TypeEnum.TypeString || proto[2].Type != TypeEnum.TypeInt) { EDB.WriteLine("publisher implements TCPROS... BADLY! parameters aren't string,int"); return; } string pub_host = proto[1].Get <string>(); int pub_port = proto[2].Get <int>(); #if DEBUG EDB.WriteLine("Connecting via tcpros to topic [" + name + "] at host [" + pub_host + ":" + pub_port + "]"); #endif TcpTransport transport = new TcpTransport(PollManager.Instance.poll_set) { _topic = name }; if (transport.connect(pub_host, pub_port)) { Connection connection = new Connection(); TransportPublisherLink pub_link = new TransportPublisherLink(this, xmlrpc_uri); connection.initialize(transport, false, null); pub_link.initialize(connection); ConnectionManager.Instance.addConnection(connection); lock (publisher_links_mutex) { addPublisherLink(pub_link); } #if DEBUG EDB.WriteLine("Connected to publisher of topic [" + name + "] at [" + pub_host + ":" + pub_port + "]"); #endif } else { EDB.WriteLine("Failed to connect to publisher of topic [" + name + "] at [" + pub_host + ":" + pub_port + "]"); } } else { EDB.WriteLine("Your xmlrpc server be talking jibber jabber, foo"); } }