예제 #1
0
    public IDataProviderRequestAsync RequestAsync(string req, JObject obj, CancellationToken?token)
    {
        FIAsyncData asyncData = new FIAsyncData();

        asyncData._isDone = false;

        if (token != null)
        {
            var checkGO = new GameObject("Checker");
            checkGO.CLUpdateAsObservable().Subscribe(x => {
                if (token.Value.IsCancellationRequested == false)
                {
                    return;
                }
                asyncData._err    = FIErr.Client_Canceled;
                asyncData._isDone = true;
                asyncData._res    = new JObject(new JProperty("err", FIErr.Client_Canceled));
                GameObject.Destroy(checkGO);
            });
        }

        cm.DelayedRun(settings.fakeDelay, () => {
            if (token != null)
            {
                if (token.Value.IsCancellationRequested == true)
                {
                    return;
                }
            }
            if (settings.showHttpReqResult)
            {
                if (obj != null)
                {
                    Debug.Log("Requesting " + req + " data=" + obj.ToString());
                }
                else
                {
                    Debug.Log("Requesting " + req + " data=null");
                }
            }

            var res = InnerRequest(req, obj);
            //			Debug.Log(res.ToString());
            asyncData._err    = res["err"].Value <FIErr>();
            asyncData._res    = res;
            asyncData._isDone = true;
            if (settings.showHttpReqResult)
            {
                Debug.Log("Result " + req + " err=" + asyncData._err.ToString() + " res=" + res.ToString());
            }
            //			isProcessing = false;
        });
        return(asyncData);
    }
예제 #2
0
    public IDataProviderRequestAsync RequestAsync(string req, JObject obj, CancellationToken?token)
    {
        FIAsyncData asyncData = new FIAsyncData();

//		Debug.Log("Requesting="+req);
        http.SendRequest(req, obj, (err, res) => {
            asyncData._isDone = true;
            asyncData._err    = err;
            asyncData._res    = res;
            if (err == FIErr.Okay)
            {
                ProcessResult(res);
            }
        });
        return(asyncData);
    }