Пример #1
0
 public XmlRpcCallState(string uri, string meth, object[] args, object rs)
 {
     this.Url          = uri;
     this.XmlRpcMethod = meth;
     args         = (object[])AdrXmlRpcConverter.Adr2XmlRpc(args);
     MethodArgs   = args;
     RequestState = rs;
 }
Пример #2
0
        private object[] Proxy(ISender sender, int maxResultsToWait, string method, object[] args)
        {
            BlockingQueue q = new BlockingQueue(maxResultsToWait);

            args = AdrXmlRpcConverter.XmlRpc2AdrParams(args);
            _rpc.Invoke(sender, q, method, args);
            ArrayList allValues = new ArrayList();
            int       counter   = 0;
            ISender   rsSender  = null;

            try {
                do
                {
                    rsSender = null;               //Reset it before the following:
                    RpcResult rpcRs = (RpcResult)q.Dequeue();
                    rsSender = rpcRs.ResultSender; //get it before exception thrown
                    object val = rpcRs.Result;
                    Debug.WriteLine(string.Format("Original Result: {0}", val));
                    object xmlrpc_val = AdrXmlRpcConverter.Adr2XmlRpc(val); //conversion in here
                    counter++;
                    allValues.Add(xmlrpc_val);
                } while (maxResultsToWait < 0 ? true : (counter < maxResultsToWait));
            } catch (Exception e) {
                Debug.WriteLine(e);
                string s = string.Empty;
                if (e is AdrException)
                {
                    if (rsSender != null)
                    {
                        s = AdrXmlRpcConverter.Adr2XmlRpc(rsSender) as string;
                    }
                }
                if (e is InvalidOperationException)
                {
                    /*
                     * this is what we expect at the end of Dequeuing, so just return what we've gotten so far
                     * it could be an empty array
                     */
                    return(allValues.ToArray());
                }
                Exception new_e = AdrXmlRpcConverter.Adr2XmlRpc(e) as Exception;
                throw new Exception(new_e.Message +
                                    (s.Equals(string.Empty) ? string.Empty : string.Format("thrown by: {0}", s)));
            } finally {
                if (!q.Closed)
                {
                    q.Close();
                }
            }
            return(allValues.ToArray());
        }
Пример #3
0
        /**
         * Fires XML-RPC call and gets the job done, then returns Brunet Rpc result.
         *
         * Calls to this method come from Brunet, go to XML-RPC and return
         * to Brunet Overlay. So conversion needed from Adr->XmlRpc.Net->Adr
         */
        public void BrunetRpc2XmlRpc(object xmlrpcCallState)
        {
            XmlRpcCallState state = (XmlRpcCallState)xmlrpcCallState;
            object          ret   = null;

            try {
                ret = state.XmlRpcCall(state.MethodArgs);
                ret = AdrXmlRpcConverter.XmlRpc2Adr(ret);
            } catch (Exception e) {
                Debug.WriteLine(e);
                ret = new AdrException(-32602, e);
            } finally {
                _node.EnqueueAction(new RpcSendResultAction(_rpc, state.RequestState, ret));
            }
        }