Exemplo n.º 1
0
        /// <summary>
        /// 创建角色.
        /// </summary>
        /// <param name="iKey">Key.</param>
        /// <param name="iRoleInfo">角色信息.</param>
        private void SetData(
            string iKey, OneSdkRoleInfo iRoleInfo)
        {
            var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            var curActivity = unityPlayer.GetStatic <AndroidJavaObject> ("currentActivity");

            if (null == curActivity)
            {
                Error("SetData():The current activity is invalid!!!");
                return;
            }
            Info("SetData()::Key:{0} RoleInfo:{1}", iKey, iRoleInfo.ToString());
            var roleInfo = new SfjsonObject();

            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);

            Info("SetData()::RoleInfo:{0}", roleInfo.toString());
            // 设定信息
            setData(curActivity.GetRawObject(), iKey, roleInfo.toString());
        }
Exemplo n.º 2
0
        private SfjsonObject readObject()
        {
            var result = new SfjsonObject();

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

            if (first == '}')
            {
                return(null);
            }

            if (first != -1)
            {
                _pos--;
            }

            while (true)
            {
                var 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.
                 */
                var 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");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 解析支付信息.
        /// </summary>
        /// <returns>Json数据对象.</returns>
        /// <param name="iJsonDetail">Json详细.</param>
        /// <param name="iOnPaymentSucceeded">支付成功回调函数.</param>
        public SdkPaymentBaseInfo ParserPayResponseInfo(
            string iJsonDetail,
            Action <SdkAccountBaseInfo, string> iOnPaymentSucceeded)
        {
            if (null == iOnPaymentSucceeded)
            {
                Warning("SDKParserPaymentInfo()::OnPaymentSucceeded is null!!!");
            }

            UpdateStatus(SdkStatus.PurchaseCompleted);
            Info("ParserPayResponseInfo()::Detail:{0}", iJsonDetail);
            var sfjson = new SfjsonObject(iJsonDetail);
            var status = (string)sfjson.get("result");

            if (string.IsNullOrEmpty(status))
            {
                Error("ParserPayResponseInfo()::Data Format Invalid!!!!(Detail:{0})", iJsonDetail);
                return(null);
            }
            var data = (string)sfjson.get("data");

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

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

            switch (status)
            {
            case SPaySuccess:
            {
                UpdateStatus(SdkStatus.PurchaseSucceeded);
                _payment.succeeded = true;

                if (null != iOnPaymentSucceeded)
                {
                    iOnPaymentSucceeded(_userInfo, _payment.orderNo);
                }
                else
                {
                    Warning("ParserPayResponseInfo()::OnPaymentSucceeded is null!!!!");
                }

                break;
            }

            case SPayFailed:
                UpdateStatus(SdkStatus.PurchaseFailed);
                _payment.succeeded = false;
                break;

            case SPayOrderNo:
                UpdateStatus(SdkStatus.PurchaseOrdered);
                _payment.succeeded = true;
                _payment.orderNo   = data;
                break;
            }
            Info("ParserPayResponseInfo()::PayInfo:{0}", _payment.ToString());
            return(_payment);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 解析登录信息.
        /// </summary>
        /// <returns>Json数据对象.</returns>
        /// <param name="iJsonDetail">Json详细.</param>
        public SdkAccountBaseInfo ParserLoginResponseInfo(string iJsonDetail)
        {
            // 登录完成
            UpdateStatus(SdkStatus.LoginCompleted);

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

            var sfjson       = new SfjsonObject(iJsonDetail);
            var status       = (string)sfjson.get("result");
            var customParams = (string)sfjson.get("customParams");

            Info("ParserLoginResponseInfo()::CustomParams:{0}", customParams);

            switch (status)
            {
            // 登出
            case SLogout:
            {
                _sfUserInfo = null;
                UpdateStatus(SdkStatus.Logouted);

                // 重登录
                if (_isLogin)
                {
                    ReLogin();
                }

                // 登录成功
                break;
            }

            case SLoginSuccess:
            {
                UpdateStatus(SdkStatus.LoginCompleted);

                var userinfoTmp = (SfjsonObject)sfjson.get("userinfo");
                if (null != userinfoTmp)
                {
                    _userInfo.userId        = long.Parse((string)userinfoTmp.get("id"));
                    _userInfo.channelId     = (string)userinfoTmp.get("channelid");
                    _userInfo.channelUserId = (string)userinfoTmp.get("channeluserid");
                    _userInfo.userName      = (string)userinfoTmp.get("username");
                    _userInfo.token         = (string)userinfoTmp.get("token");
                    _userInfo.productCode   = (string)userinfoTmp.get("productcode");
                    _sfUserInfo             = new SFOnlineUser(
                        _userInfo.userId,
                        _userInfo.channelId,
                        _userInfo.channelUserId,
                        _userInfo.userName,
                        _userInfo.token,
                        _userInfo.productCode);
                }
                if (null != _loginCheckCallback)
                {
                    // 校验数据
                    var checkInfo = GetLoginCheckInfoJson(_userInfo);
                    if (string.IsNullOrEmpty(checkInfo))
                    {
                        Error("ParserLoginResponseInfo():JsonConvert Failed!!!(Data:{0})",
                              _userInfo.ToString());
                        UpdateStatus(SdkStatus.LoginCheckFailed);
                        return(null);
                    }
                    Info("ParserLoginResponseInfo()::CheckInfo:{0}", checkInfo);
                    _loginCheckCallback(checkInfo, _loginCheckSucceeded, _loginCheckFailed);
                }
                else
                {
                    // 登录校验&更新状态
                    LoginCheck(_userInfo);
                }

                // 登录失败
                break;
            }

            case SLoginFailed:
            {
                UpdateStatus(SdkStatus.LoginFailed);
                // 重登录
                if (_isLogin)
                {
                    ReLogin();
                }

                break;
            }
            }
            Info("ParserLoginResponseInfo()::UserResultInfo:{0}", _userInfo.ToString());
            return(_userInfo);
        }