/// <summary>
        /// 创建 Web 请求成功事件。
        /// </summary>
        /// <param name="serialId">Web 请求任务的序列编号。</param>
        /// <param name="webRequestUri">Web 请求地址。</param>
        /// <param name="webResponseBytes">Web 响应的数据流。</param>
        /// <param name="ErrorMessage">返回错误消息。</param>
        /// <returns>创建的 Web 请求成功事件。</returns>
        public static WebRequestAwaitEventArgs Create(int serialId, string webRequestUri, byte[] webResponseBytes, string errorMessage, WebRequestCallBackStatus requestCallBackStatus)
        {
            WebRequestAwaitEventArgs webRequestAwaitEventArgs = ReferencePool.Acquire <WebRequestAwaitEventArgs>();

            webRequestAwaitEventArgs.SerialId                   = serialId;
            webRequestAwaitEventArgs.WebRequestUri              = webRequestUri;
            webRequestAwaitEventArgs.m_WebResponseBytes         = webResponseBytes;
            webRequestAwaitEventArgs.m_ErrorMessage             = errorMessage;
            webRequestAwaitEventArgs.m_WebResponseComplete      = true;
            webRequestAwaitEventArgs.m_WebRequestCallBackStatus = requestCallBackStatus;
            return(webRequestAwaitEventArgs);
        }
Exemple #2
0
        public async void AwaitWebRequestVersion()
        {
            //当网络不可用时
            if (!CheckNetworkReachability())
            {
                return;
            }

            WebResponseComplete = false;
            WebResponseSuccess  = false;

            L0_Text.This.m_MCycle_LoadRes.visible = true;

            //正在获取版本信息...
            L0_Text.This.m_Text_Mseg
            .SetGTextByCode("Text_Mseg_002");

            try
            {
                //获取最新的版本信息
                WebRequest = await CentorPivot.This.GetComponent <WebRequestComponent>().AwaitGetWebRequest(
                    Utility.Text.Format("{0}{1}", SettingComponent.This.UrlInfo().GetWebUrl(), GlobalData.Restful.Version)
                    );

                byte[] webData = WebRequest.GetWebResponseBytes();

                if (string.IsNullOrEmpty(WebRequest.ErrorMessage) && webData != null && webData.Length > 0)
                {
                    string responseJson = Utility.Converter.GetString(webData);

                    //Log.Info(responseJson);

                    //解析字符串
                    HttpResult ret = JsonHelper.ToObject <HttpResult>(responseJson);

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

                        WebResponseSuccess = false;
                    }
                    else
                    {
                        SettingComponent.This.VersionInfo = JsonHelper.ToObject <Version>((string)ret.data);

                        WebResponseSuccess = true;
                    }
                }
                else
                {
                    Log.Info(WebRequest.ErrorMessage, LogCategory.Proto);

                    WebResponseSuccess = false;
                }
            }
            catch (Exception e)
            {
                Log.Info(e.ToString(), LogCategory.Proto);

                WebResponseSuccess = false;
            }
            finally
            {
                WebResponseComplete = true;
            }
        }
Exemple #3
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);
            }
        }