Пример #1
0
        /// <summary>
        /// 异步方法
        /// </summary>
        /// <typeparam name="TArgs"></typeparam>
        /// <param name="url"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        /// <param name="callback"></param>
        public static void BeginInvoke(string serviceUri, string module, string method, string reqBody, Action <JsonRpcResponse> callback)
        {
            JsonRpcHttpClientTransaction proxy = new JsonRpcHttpClientTransaction();
            JsonRpcRequest rpcReq = new JsonRpcRequest(serviceUri, reqBody);

            rpcReq.AddHeader("UU-REQUEST-MODULE", module);
            rpcReq.AddHeader("UU-REQUEST-ACTION", method);
            rpcReq.AddHeader("UU-AUTH-TYPE", "2");
            proxy.SendRequest(rpcReq, (rpcResponse) =>
            {
                callback(rpcResponse);
            });
        }
Пример #2
0
        public static JsonRpcResponse Invoke(string serviceUri, string module, string method, string reqBody)
        {
            JsonRpcResponse resp = null;
            JsonRpcHttpClientTransaction proxy = new JsonRpcHttpClientTransaction();


            SyncInvoker    sync   = new SyncInvoker();
            JsonRpcRequest rpcReq = new JsonRpcRequest(serviceUri, reqBody);

            rpcReq.AddHeader("UU-REQUEST-MODULE", module);
            rpcReq.AddHeader("UU-REQUEST-ACTION", method);
            rpcReq.AddHeader("UU-AUTH-TYPE", "2");
            proxy.SendRequest(rpcReq, (rpcResponse) =>
            {
                resp = rpcResponse;
                sync.Callback();
            });

            sync.Wait(1000 * 80);
            return(resp);
        }