Example #1
0
        public virtual void RegisterUser()
        {
            var url           = CTaskUtil.REGISTER_URL;
            var header        = CTaskUtil.VERIFY_HEADERS;
            var registerParam = new Dictionary <string, string> ();

            registerParam ["uname"]        = this.currentUser.userName;
            registerParam ["upass"]        = this.currentUser.userPassword;
            registerParam ["uemail"]       = this.currentUser.userEmail;
            registerParam ["udisplayname"] = this.currentUser.userDisplayName;
            registerParam ["uloginmethod"] = "ANDROID";
            bool canSubmit = string.IsNullOrEmpty(this.currentUser.userName) == false &&
                             string.IsNullOrEmpty(this.currentUser.userPassword) == false &&
                             string.IsNullOrEmpty(this.currentUser.userEmail) == false &&
                             string.IsNullOrEmpty(this.currentUser.userDisplayName) == false;

            if (canSubmit)
            {
                var request = new CRequest(url, header);
                request.Post(url, registerParam, (CResult obj) => {
                    var objContent = obj.ToJSONObject();
                    if (objContent.ContainsKey("resultCode"))
                    {
                        var userResponse            = objContent ["resultContent"] as Dictionary <string, object>;
                        currentUser.userName        = userResponse ["userName"].ToString();
                        currentUser.userEmail       = userResponse ["userEmail"].ToString();
                        currentUser.userDisplayName = userResponse ["userDisplayName"].ToString();
                        currentUser.token           = userResponse ["token"].ToString();
                        this.OnClientRegisterCompleted(currentUser);
                    }
                    else if (objContent.ContainsKey("errorCode"))
                    {
                        var errorContent = objContent ["errorContent"].ToString();
                        this.OnClientError(errorContent);
                    }
                }, (err) => {
                    this.OnClientError(err);
                }, null);
                // Start loading UI.
                CUICustomManager.Instance.ActiveLoading(true);
            }
            else
            {
                this.OnClientError("Field do not empty.");
            }
            // INIT
            this.m_Inited = false;
        }