/// <summary>
        /// 增加Web请求任务(可等待)
        /// </summary>
        public CFTask <WebRequestAwaitEventArgs> AwaitPostWebRequest(string webRequestUri, Dictionary <string, object> postDic)
        {
            if (postDic == null)
            {
                postDic = VarDicSO.NewValue();
            }

            //客户端标识符
            postDic["deviceIdentifier"] = DeviceUtil.DeviceIdentifier;

            //设备型号
            postDic["deviceModel"] = DeviceUtil.DeviceModel;

            //当前服务器时间
            long ts = Utility.Timer.ClientNowSeconds();

            //签名
            postDic["sign"] = Utility.Encryption.Md5(Utility.Text.Format("{0}:{1}+{2}:{3}/{4}", DeviceUtil.DeviceIdentifier, DeviceUtil.DeviceModel, AppId, AppKey, ts), Salt);

            //时间戳
            postDic["ts"] = ts;

            string json = JsonHelper.ToJson(postDic);

            byte[] postData = Utility.Converter.GetBytes(json);

            return(AwaitAddWebRequest(webRequestUri, postData, ConstData.Priority.Default));
        }
示例#2
0
        //=================  选择登录方式 =====================
        #region 游戏登陆方式

        #region 1、QuestLogin 游客注册并登录

        /// <summary>
        /// 游客注册并登录
        /// </summary>
        /// <param name="loginType">登录方式</param>
        /// <param name="timeAction">时间代理</param>
        public static async void QuestLogin(LoginType loginType, TimeAction timeAction)
        {
            Dictionary <string, object> dic = VarDicSO.NewValue();

            dic["AUTHKEY"] = "";

            try
            {
                //游客模式登陆 第一次登陆,用户和密码为空\第二次登陆之后 根据 UUID 和 授权码进行自动登陆
                PlayerInfo playerInfo = SettingComponent.This.GetObject <PlayerInfo>(GlobalData.CookieSets.Cookie_Quick);

                if (playerInfo != null)
                {
                    dic["AUTHKEY"] = playerInfo.AuthorizedSKey;
                }

                WebRequestAwaitEventArgs webRequest = await WebRequestLogin(dic, loginType);

                if (webRequest.WebRequestCallBackStatus == WebRequestCallBackStatus.Success)
                {
                    string responseJson = Utility.Converter.GetString(webRequest.GetWebResponseBytes());

                    HttpResult ret = JsonHelper.ToObject <HttpResult>(responseJson);

                    //返回登录成功or失败信息
                    P6_LoginMesg.This.m_Text_LoginMesg
                    .SetGTextByCode(ret.code.ToString());

                    if (!ret.status)
                    {
                        Log.Error(ret.code.ToString() + responseJson, LogCategory.Proto);

                        //执行结束 结束异步时间代理调用
                        timeAction?.EndLoop();
                    }
                    else
                    {
                        timeAction.CFParams.BoolParam1 = true;

                        //关闭用户信息面板
                        Login_Account.PageToAccount_Close();

                        Log.Info(ret.code.ToString() + responseJson, LogCategory.Proto);

                        //获取到网关信息
                        LoginFromRealmCallback(ret.data?.ToString(), loginType, timeAction);
                    }
                }
                else
                {
                    P6_LoginMesg.This
                    .m_Text_LoginMesg
                    .SetGTextByValue(webRequest.ErrorMessage);

                    Log.Info(webRequest.ErrorMessage, LogCategory.Proto);

                    //执行结束 结束异步时间代理调用
                    timeAction?.EndLoop();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, LogCategory.Proto);
            }
        }