Esempio n. 1
0
        public void Login(string uid)
        {
            this.isBusy = true;
            this.uid    = uid;
            this.token  = "";

            var postData = new Dictionary <string, string>();

            postData["uid"] = uid;
            Post("login", postData, (content) =>
            {
                var obj   = JsonMapper.ToObject(content);
                var token = new TokenResult();
                token.Parse(obj);
                if (token.isOK)
                {
                    this.token = token.token;
                    onBegin?.Invoke(token);
                    StateLoop();
                }
                else
                {
                    onError?.Invoke(token);
                }
            });
        }
Esempio n. 2
0
        public void Download(string uid, string csdn, string url)
        {
            if (this.isBusy)
            {
                return;
            }

            this.isBusy = true;
            this.uid    = uid;
            this.token  = "";

            var postData = new Dictionary <string, string>();

            postData["uid"]  = uid;
            postData["csdn"] = csdn;
            postData["url"]  = url;
            Post("download", postData, (content) =>
            {
                var obj   = JsonMapper.ToObject(content);
                var token = new TokenResult();
                token.Parse(obj);
                if (token.isOK)
                {
                    this.token = token.token;
                    onBegin?.Invoke(token);
                    StateLoop();
                }
                else
                {
                    onError?.Invoke(token);
                }
            });
        }