Exemple #1
0
        public bool NegotiateConnection(string xmlrpc_uri)
        {
            int         protos = 0;
            XmlRpcValue tcpros_array = new XmlRpcValue(), protos_array = new XmlRpcValue(), Params = new XmlRpcValue();

            tcpros_array.Set(0, "TCPROS");
            protos_array.Set(protos++, tcpros_array);
            Params.Set(0, this_node.Name);
            Params.Set(1, name);
            Params.Set(2, protos_array);
            string peer_host = "";
            int    peer_port = 0;

            if (!network.splitURI(xmlrpc_uri, ref peer_host, ref peer_port))
            {
                EDB.WriteLine("Bad xml-rpc URI: [" + xmlrpc_uri + "]");
                return(false);
            }
            // test
//			if ( peer_host == "udacity" )
//				peer_host = "192.168.30.111";
            // end test
            XmlRpcClient c = new XmlRpcClient(peer_host, peer_port);

            if (!c.IsConnected || !c.ExecuteNonBlock("requestTopic", Params))
            {
                EDB.WriteLine("Failed to contact publisher [" + peer_host + ":" + peer_port + "] for topic [" + name +
                              "]");
                c.Dispose();
                return(false);
            }
#if DEBUG
            EDB.WriteLine("Began asynchronous xmlrpc connection to http://" + peer_host + ":" + peer_port + "/ for topic [" + name +
                          "]");
#endif
            PendingConnection conn = new PendingConnection(c, this, xmlrpc_uri, Params);
            lock (pending_connections_mutex)
            {
                pending_connections.Add(conn);
            }
            XmlRpcManager.Instance.addAsyncConnection(conn);
            return(true);
        }
 public bool ExecuteNonBlock(string method, XmlRpcValue parameters)
 {
     lock (client_lock)
         return(client.ExecuteNonBlock(method, parameters));
 }