示例#1
0
        private void StateLoop()
        {
            isStateOver = false;
            var postData = new Dictionary <string, string>();

            postData["uid"]   = uid;
            postData["token"] = token;
            IntervalPost("download_get_state", postData, (_content) =>
            {
                var _obj  = JsonMapper.ToObject(_content);
                var state = new DownloadStateResult();
                state.Parse(_obj);
                if (state.isOK)
                {
                    onProcess?.Invoke(state);
                    if (state.isDone)
                    {
                        var done = new DownloadResult();
                        done.Parse(_obj);
                        onFinish?.Invoke(done);
                        _Over();
                    }
                    else if (state.isFail)
                    {
                        onError?.Invoke(state);
                        _Over();
                    }
                }
                else
                {
                    onError?.Invoke(state);
                    _Over();
                }
            }, 1, () => { return(!isStateOver); }, 3600);
        }
示例#2
0
        public void DownloadGet(string id, Action <DownloadResult> callback)
        {
            var postData = new Dictionary <string, string>();

            postData["id"] = id;
            Post("download_get", postData, (content) =>
            {
                var obj = JsonMapper.ToObject(content);
                var res = new DownloadResult();
                res.Parse(obj);
                callback?.Invoke(res);
            });
        }