Esempio n. 1
0
        private SFJSONObject readObject()
        {
            SFJSONObject result = new SFJSONObject();

            /* Peek to see if this is the empty object. */
            int first = nextCleanInternal();

            if (first == '}')
            {
                return(null);
            }
            else if (first != -1)
            {
                pos--;
            }

            while (true)
            {
                Object name = nextValue();
                //APaymentHelperDemo.toAndroidLog(tag, "readObject name:" + name);

                /*
                 * Expect the name/value separator to be either a colon ':', an
                 * equals sign '=', or an arrow "=>". The last two are bogus but we
                 * include them because that's what the original implementation did.
                 */
                int separator = nextCleanInternal();
                if (separator != ':' && separator != '=')
                {
                    //throw syntaxError("Expected ':' after " + name);
                    //	    APaymentHelperDemo.toAndroidLog(tag, "Expected ':' after " + name);
                    return(null);
                }
                if (pos < ins.Length && ins.Substring(pos, 1).ToCharArray()[0] == '>')
                {
                    pos++;
                }
                result.put((string)name, nextValue());

                switch (nextCleanInternal())
                {
                case '}':
                    return(result);

                case ';':
                case ',':
                    continue;

                default:
                    //        APaymentHelperDemo.toAndroidLog(tag, "Unterminated object");
                    return(null);
                    // throw syntaxError("Unterminated object");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 创建角色.
        /// </summary>
        /// <param name="iKey">Key.</param>
        /// <param name="iRoleInfo">角色信息.</param>
        private void SetData(
            string iKey, OneSDKRoleInfo iRoleInfo)
        {
            AndroidJavaClass _unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

            if (null == _unityPlayer)
            {
                this.Error("SetData():The unity player is invalid!!!");
                return;
            }
            AndroidJavaObject _curActivity = _unityPlayer.GetStatic <AndroidJavaObject> ("currentActivity");

            if (null == _curActivity)
            {
                this.Error("SetData():The current activity is invalid!!!");
                return;
            }
            this.Info("SetData()::Key:{0} RoleInfo:{1}", iKey, iRoleInfo.ToString());
            SFJSONObject _roleInfo = new SFJSONObject();

            if (null == _roleInfo)
            {
                this.Error("CreateRole():Memory New Error(SFJSONObject)!!!");
                return;
            }
            _roleInfo.put("roleId", iRoleInfo.ID);
            _roleInfo.put("roleName", iRoleInfo.Name);
            _roleInfo.put("roleLevel", iRoleInfo.Level);
            _roleInfo.put("zoneId", iRoleInfo.ZoneID);
            _roleInfo.put("zoneName", iRoleInfo.ZoneName);
            _roleInfo.put("balance", iRoleInfo.Balance);
            _roleInfo.put("vip", iRoleInfo.Vip);
            _roleInfo.put("partyName", iRoleInfo.PartyName);
            _roleInfo.put("roleCTime", iRoleInfo.CTime);
            _roleInfo.put("roleLevelMTime", iRoleInfo.RoleLevelMTime);

            this.Info("SetData()::RoleInfo:{0}", _roleInfo.toString());
            // 设定信息
            setData(_curActivity.GetRawObject(), iKey, _roleInfo.toString());
        }
Esempio n. 3
0
        /// <summary>
        /// 解析支付信息.
        /// </summary>
        /// <returns>Json数据对象.</returns>
        /// <param name="iJsonDetail">Json详细.</param>
        /// <param name="iOnPaymentSuccessed">支付成功回调函数.</param>
        public SDKPaymentBaseInfo ParserPayResponseInfo(
            string iJsonDetail,
            Action <SDKAccountBaseInfo, string> iOnPaymentSuccessed)
        {
            if (null == iOnPaymentSuccessed)
            {
                this.Warning("SDKParserPaymentInfo()::OnPaymentSuccessed is null!!!");
            }

            this.UpdateStatus(SDKStatus.PurchaseCompleted);
            this.Info("ParserPayResponseInfo()::Detail:{0}", iJsonDetail);
            SFJSONObject _sfjson = new SFJSONObject(iJsonDetail);

            if (null == _sfjson)
            {
                this.Error("ParserPayResponseInfo()::(SFJSONObject)Memory New Error!!!!");
                return(null);
            }
            string _status = (string)_sfjson.get("result");

            if (true == string.IsNullOrEmpty(_status))
            {
                this.Error("ParserPayResponseInfo()::Data Format Invalid!!!!(Detail:{0})", iJsonDetail);
                return(null);
            }
            string _data = (string)_sfjson.get("data");

            if (true == string.IsNullOrEmpty(_data))
            {
                this.Error("ParserPayResponseInfo()::Data Format Invalid!!!!(Detail:{0})", iJsonDetail);
                return(null);
            }

            if (null == this._payment)
            {
                this._payment = new OneSDKPaymentInfo();
                this._payment.Reset();
            }
            if (null == this._payment)
            {
                this.Error("ParserPayResponseInfo()::(OneSDKPaymentInfo)Memory New Error!!!!");
                return(null);
            }

            if (true == S_PAY_SUCCESS.Equals(_status))
            {
                this.UpdateStatus(SDKStatus.PurchaseSuccessed);
                this._payment.Successed = true;

                if (null != iOnPaymentSuccessed)
                {
                    iOnPaymentSuccessed(this._userInfo, this._payment.OrderNo);
                }
                else
                {
                    this.Warning("ParserPayResponseInfo()::OnPaymentSuccessed is null!!!!");
                }
            }
            else if (true == S_PAY_FAILED.Equals(_status))
            {
                this.UpdateStatus(SDKStatus.PurchaseFailed);
                this._payment.Successed = false;
            }
            else if (true == S_PAY_ORDER_NO.Equals(_status))
            {
                this.UpdateStatus(SDKStatus.PurchaseOrdered);
                this._payment.Successed = true;
                this._payment.OrderNo   = _data;
            }
            this.Info("ParserPayResponseInfo()::PayInfo:{0}", this._payment.ToString());
            return(this._payment);
        }
Esempio n. 4
0
        /// <summary>
        /// 解析登录信息.
        /// </summary>
        /// <returns>Json数据对象.</returns>
        /// <param name="iJsonDetail">Json详细.</param>
        public SDKAccountBaseInfo ParserLoginResponseInfo(string iJsonDetail)
        {
            // 登录完成
            this.UpdateStatus(SDKStatus.LoginCompleted);

            if (null == this._userInfo)
            {
                this._userInfo = new OneSDKUserInfo();
            }
            if (null == this._userInfo)
            {
                this.Error("ParserLoginResponseInfo()::Memory New Error!!!!");
                return(this._userInfo);
            }
            this._userInfo.Reset();

            SFJSONObject _sfjson = new SFJSONObject(iJsonDetail);

            if (null == _sfjson)
            {
                return(null);
            }
            string _status       = (string)_sfjson.get("result");
            string _customParams = (string)_sfjson.get("customParams");

            this.Info("ParserLoginResponseInfo()::CustomParams:{0}", _customParams);

            // 登出
            if (true == S_LOGOUT.Equals(_status))
            {
                this._sfUserInfo = null;
                this.UpdateStatus(SDKStatus.Logouted);

                // 重登录
                if (true == this._isLogin)
                {
                    this.ReLogin();
                }

                // 登录成功
            }
            else if (true == S_LOGIN_SUCCESS.Equals(_status))
            {
                this.UpdateStatus(SDKStatus.LoginCompleted);

                SFJSONObject _userinfoTmp = (SFJSONObject)_sfjson.get("userinfo");
                if (null != _userinfoTmp)
                {
                    this._userInfo.UserID        = long.Parse((string)_userinfoTmp.get("id"));
                    this._userInfo.ChannelId     = (string)_userinfoTmp.get("channelid");
                    this._userInfo.ChannelUserId = (string)_userinfoTmp.get("channeluserid");
                    this._userInfo.UserName      = (string)_userinfoTmp.get("username");
                    this._userInfo.Token         = (string)_userinfoTmp.get("token");
                    this._userInfo.ProductCode   = (string)_userinfoTmp.get("productcode");
                    this._sfUserInfo             = new SFOnlineUser(
                        this._userInfo.UserID,
                        this._userInfo.ChannelId,
                        this._userInfo.ChannelUserId,
                        this._userInfo.UserName,
                        this._userInfo.Token,
                        this._userInfo.ProductCode);
                }
                if (null != this._loginCheckCallback)
                {
                    // 校验数据
                    string _checkInfo = GetLoginCheckInfoJson(this._userInfo);
                    if (true == string.IsNullOrEmpty(_checkInfo))
                    {
                        this.Error("ParserLoginResponseInfo():JsonConvert Failed!!!(Data:{0})",
                                   this._userInfo.ToString());
                        this.UpdateStatus(SDKStatus.LoginCheckFailed);
                        return(null);
                    }
                    this.Info("ParserLoginResponseInfo()::CheckInfo:{0}", _checkInfo);
                    this._loginCheckCallback(_checkInfo, this._loginCheckSuccessed, this._loginCheckFailed);
                }
                else
                {
                    // 登录校验&更新状态
                    loginCheck(this._userInfo);
                }

                // 登录失败
            }
            else if (true == S_LOGIN_FAILED.Equals(_status))
            {
                this.UpdateStatus(SDKStatus.LoginFailed);
                // 重登录
                if (true == this._isLogin)
                {
                    this.ReLogin();
                }
            }
            this.Info("ParserLoginResponseInfo()::UserResultInfo:{0}", this._userInfo.ToString());
            return(this._userInfo);
        }