public IEnumerator DownloadNotice() { WWW d = new WWW(SystemConfig.GetCfgInfoUrl(SystemConfig.NOTICE_URL_KEY)); Mogo.Util.LoggerHelper.Debug(SystemConfig.GetCfgInfoUrl(SystemConfig.NOTICE_URL_KEY)); yield return(d); noticeXml = d.text; Mogo.Util.LoggerHelper.Debug(d.text); #if UNITY_IPHONE //use native md5 interface string md5 = IOSUtils.FormatMD5(IOSUtils.CreateMD5(d.bytes)); #else string md5 = Utils.FormatMD5(Utils.CreateMD5(d.bytes)); #endif Mogo.Util.LoggerHelper.Debug("md5:" + md5); if (SystemConfig.Instance.noticeMd5 == md5 && SystemConfig.Instance.Passport == SystemConfig.Instance.PassportSeenNotice) { yield break; } SystemConfig.Instance.noticeMd5 = md5; SystemConfig.Instance.PassportSeenNotice = SystemConfig.Instance.Passport; SystemConfig.SaveConfig(); if (DownloadFinished != null && !MogoWorld.BeginLogin)//如果开始登录了就不打开公告板 { DownloadFinished(); } IsDownloadFinished = true; }
public void BeforeCheck(Action <UpdateType> AsynResult, Action OnError) { this.ServerVersion = new VersionManagerInfo(); PropertyInfo[] properties = typeof(VersionManagerInfo).GetProperties(); try { foreach (PropertyInfo info in properties) { if (info != null) { string cfgInfoUrl = SystemConfig.GetCfgInfoUrl(info.Name); if (!string.IsNullOrEmpty(cfgInfoUrl)) { object obj2 = Utils.GetValue(cfgInfoUrl, info.PropertyType); if (obj2 != null) { info.SetValue(this.ServerVersion, obj2, null); } } } } } catch (Exception exception) { LoggerHelper.Error("Get ServerVersion error: " + exception.Message, true); } LoggerHelper.Debug("服务器程序版本: " + this.ServerVersion.ProgramVersionInfo, true, 0); LoggerHelper.Debug("服务器资源版本: " + this.ServerVersion.ResouceVersionInfo, true, 0); LoggerHelper.Debug("服务器首包资源版本TinyPackageFirstResourceVersionInfo: " + this.ServerVersion.TinyPackageFirstResourceVersionInfo, true, 0); LoggerHelper.Debug("服务器完整包资源版本CompletePackageFullResourceVersionInfo: " + this.ServerVersion.CompletePackageFullResourceVersionInfo, true, 0); LoggerHelper.Debug("服务器首包资源版本FirstResourceVersion: " + this.ServerVersion.FirstResourceVersion, true, 0); LoggerHelper.Debug("服务器完整包资源版本FullResourceVersion: " + this.ServerVersion.FullResourceVersion, true, 0); LoggerHelper.Debug("服务器是否打开完整包下载:" + this.ServerVersion.IsOpenUrl, true, 0); LoggerHelper.Debug("服务器Apk地址: " + this.ServerVersion.ApkUrl, true, 0); LoggerHelper.Debug("服务器是否打开首包下载:" + this.ServerVersion.IsFirstPkgOpenUrl, true, 0); LoggerHelper.Debug("服务器Small Apk地址: " + this.ServerVersion.FirstApkUrl, true, 0); LoggerHelper.Debug("服务器增量包地址: " + this.ServerVersion.PackageUrl, true, 0); LoggerHelper.Debug("服务器md5地址: " + this.ServerVersion.PackageMd5List, true, 0); LoggerHelper.Debug("导出开关: " + this.ServerVersion.ExportSwitch, true, 0); LoggerHelper.Debug("平台更新开关: " + this.ServerVersion.IsPlatformUpdate, true, 0); LoggerHelper.Debug("聊天语音地址: " + this.ServerVersion.VoiceUrl, true, 0); bool flag = this.ServerVersion.CompletePackageFullResourceVersionInfo.Compare(this.LocalVersion.CompletePackageFullResourceVersionInfo) > 0; LoggerHelper.Debug("compareFullProgramVersion: " + flag, true, 0); bool flag2 = this.ServerVersion.ProgramVersionInfo.Compare(this.LocalVersion.ProgramVersionInfo) > 0; LoggerHelper.Debug("compareProgramVersion: " + flag2, true, 0); if (flag) { bool flag3 = this.ServerVersion.TinyPackageFirstResourceVersionInfo.Compare(this.LocalVersion.TinyPackageFirstResourceVersionInfo) > 0; AsynResult.BeginInvoke((flag2 || flag3) ? UpdateType.FirstRes : UpdateType.None, null, null); } else { bool flag4 = this.ServerVersion.ResouceVersionInfo.Compare(this.LocalVersion.ResouceVersionInfo) > 0; LoggerHelper.Debug("compareResourceVersion: " + flag4, true, 0); AsynResult.BeginInvoke((flag2 || flag4) ? UpdateType.NormalRes : UpdateType.None, null, null); } }
public void BeforeCheck(Action <UpdateType> AsynResult, Action OnError) { ServerVersion = new VersionManagerInfo(); var props = typeof(VersionManagerInfo).GetProperties(); try { foreach (var prop in props) { if (prop != null) { var target = SystemConfig.GetCfgInfoUrl(prop.Name); if (!string.IsNullOrEmpty(target)) { var value = Utils.GetValue(target, prop.PropertyType); if (value != null) { prop.SetValue(ServerVersion, value, null); } } } } } catch (Exception ex) { LoggerHelper.Error("Get ServerVersion error: " + ex.Message); } PlayerLogInfo.ServerResVersion = LocalVersion.ResourceVersionInfo.ToString(); Mogo.Util.LoggerHelper.Debug("服务器程序版本: " + ServerVersion.ProgramVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器资源版本: " + ServerVersion.ResourceVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器首包资源版本: " + ServerVersion.FirstResourceVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器完整包资源版本: " + ServerVersion.FullResourceVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器包地址: " + ServerVersion.PackageUrl); Mogo.Util.LoggerHelper.Debug("服务器Apk地址: " + ServerVersion.ApkUrl); Mogo.Util.LoggerHelper.Debug("服务器Small Apk地址: " + ServerVersion.FirstApkUrl); Mogo.Util.LoggerHelper.Debug("服务器md5地址: " + ServerVersion.PackageMd5List); Mogo.Util.LoggerHelper.Debug("导出开关: " + ServerVersion.ExportSwitch); Mogo.Util.LoggerHelper.Debug("平台更新开关: " + ServerVersion.IsPlatformUpdate); var compareFullProgramVersion = ServerVersion.FullResourceVersionInfo.Compare(LocalVersion.FullResourceVersionInfo) > 0; //服务首包资源版本号比本地版本号大 var compareProgramVersion = ServerVersion.ProgramVersionInfo.Compare(LocalVersion.ProgramVersionInfo) > 0; //服务程序版本号比本地版本号大 if (compareFullProgramVersion) { var compareFirstProgramVersion = ServerVersion.FirstResourceVersionInfo.Compare(LocalVersion.FirstResourceVersionInfo) > 0;//服务首包资源版本号比本地版本号大 AsynResult.BeginInvoke((compareProgramVersion || compareFirstProgramVersion) ? UpdateType.FirstRes : UpdateType.None, null, null); } else { var compareResourceVersion = ServerVersion.ResourceVersionInfo.Compare(LocalVersion.ResourceVersionInfo) > 0;//服务器资源版本比本地高 LoggerHelper.Debug("compareResourceVersion: " + compareResourceVersion); AsynResult.BeginInvoke((compareProgramVersion || compareResourceVersion) ? UpdateType.NormalRes : UpdateType.None, null, null); } }
public void UploadLogFile(string fileName, string content) { var param = string.Format("filename={0}&content={1}", fileName, content); var bs = System.Text.Encoding.UTF8.GetBytes(param); var req = HttpWebRequest.Create(SystemConfig.GetCfgInfoUrl(LogPath)); req.Method = "post"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = bs.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); } }
public void UploadLogFile(string fileName, string content) { string s = string.Format("filename={0}&content={1}", fileName, content); byte[] bytes = Encoding.UTF8.GetBytes(s); WebRequest request = WebRequest.Create(SystemConfig.GetCfgInfoUrl("logurl")); request.Method = "post"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = bytes.Length; using (Stream stream = request.GetRequestStream()) { stream.Write(bytes, 0, bytes.Length); } }
private IEnumerator DownloadMarket() { MarketData.dataMap.Clear(); items.Clear(); WWW d = new WWW(SystemConfig.GetCfgInfoUrl(SystemConfig.MARKET_URL_KEY)); yield return(d); var xml = XMLParser.LoadXML(d.text); var map = XMLParser.LoadIntMap(xml, SystemConfig.MARKET_URL_KEY); var type = typeof(MarketData); var props = type.GetProperties(); foreach (var item in map) { var t = new MarketData(); foreach (var prop in props) { if (prop.Name == "id") { prop.SetValue(t, item.Key, null); } else { if (item.Value.ContainsKey(prop.Name)) { var value = Utils.GetValue(item.Value[prop.Name], prop.PropertyType); prop.SetValue(t, value, null); } } } if (!MarketData.dataMap.ContainsKey(item.Key)) { MarketData.dataMap.Add(item.Key, t); } version = t.marketVersion; items.Add(new MarketItem(t)); } foreach (var i in items) { if (i.resData.mode == 2) {//限购 GetLimitNum(i.resData.marketVersion, i.resData.id); } } ShowMarketUIByTab(); }
public void AsynIsNetworkTimeout(Action <bool> AsynResult) { string networkUrl; if (File.Exists(SystemConfig.CfgPath)) { var result = SystemConfig.LoadCfgInfo(); networkUrl = SystemConfig.GetCfgInfoUrl(SystemConfig.VERSION_URL_KEY); LoggerHelper.Info("cfg exist. " + result + " networkUrl: " + networkUrl); } else { networkUrl = Utils.LoadResource(Utils.GetFileNameWithoutExtention(SystemConfig.CFG_FILE)); } var counter = 0; TryAsynDownloadText(networkUrl, counter, AsynResult); }
public void AsynIsNetworkTimeout(Action <bool> AsynResult) { string cfgInfoUrl; if (File.Exists(SystemConfig.CfgPath)) { bool flag = SystemConfig.LoadCfgInfo(); cfgInfoUrl = SystemConfig.GetCfgInfoUrl("version"); LoggerHelper.Info(string.Concat(new object[] { "cfg exist. ", flag, " networkUrl: ", cfgInfoUrl }), true); } else { cfgInfoUrl = Utils.LoadResource(Utils.GetFileNameWithoutExtention("cfg.xml", '/')); } int counter = 0; this.TryAsynDownloadText(cfgInfoUrl, counter, AsynResult); }
protected override void OnResourceLoaded() { var parent = MogoWorld.m_uiManager.MogoMainUIPanel; SyncCreateUIInstanceWithRootTransform(Resources[0], parent); m_myTransform.localPosition = new Vector3(0f, -30f, 0f); var btnCreate = FindComponent <MogoUIBtn>("BtnCreateServer"); btnCreate.SetText(LanguageData.GetContent(1)); btnCreate.ClickAction = OnBtnCreate; var btnFind = FindComponent <MogoUIBtn>("BtnFindServer"); btnFind.SetText(LanguageData.GetContent(2)); btnFind.ClickAction = OnBtnFind; var btnJoin = FindComponent <MogoUIBtn>("BtnJoin"); btnJoin.SetText(LanguageData.GetContent(11)); btnJoin.ClickAction = OnBtnJoin; var btnScanJoin = FindComponent <MogoUIBtn>("BtnScanJoin"); btnScanJoin.SetText(LanguageData.GetContent(12)); btnScanJoin.ClickAction = OnBtnScanJoin; m_inputPlayerName = FindComponent <UIInput>("PlayerName"); m_inputPlayerName.text = UtilsEx.GetRandomName(); m_inputPlayerName.maxChars = NAME_MAX_LENGTH; m_inputPlayerName.onSubmit = OnSubmitName; m_inputPlayerName.lostFocusAction = OnLostFocusInputName; m_inputPlayerName.functionName = "OnSubmitName"; FindComponent <UILabel>("LblPlayerName").text = LanguageData.GetContent(10); m_inputServerIP = FindComponent <UIInput>("ServerIP"); m_inputServerIP.text = SystemConfig.GetCfgInfoUrl("serverlist"); m_inputServerIP.onSubmit = OnSubmitName; FindComponent <UILabel>("LblIP").text = LanguageData.GetContent(9); var btnGuide = FindComponent <MogoUIBtn>("BtnWenHao"); btnGuide.ClickAction = OnBtnGuide; }
public void BeforeCheck(Action <bool> AsynResult, Action OnError) { new CheckTimeout().AsynIsNetworkTimeout(delegate(bool success) { Action <string> asynResult = null; if (success) { if (asynResult == null) { asynResult = delegate(string serverVersion) { if (File.Exists(SystemConfig.ServerVersionPath)) { serverVersion = Utils.LoadFile(SystemConfig.ServerVersionPath); LoggerHelper.Info("serverVersion exist:\n" + serverVersion, true); } this.ServerVersion = this.GetVersionInXML(serverVersion); if (this.ServerVersion.IsDefault()) { if (OnError != null) { OnError(); } } else { LoggerHelper.Debug("服务器程序版本: " + this.ServerVersion.ProgramVersionInfo, true, 0); LoggerHelper.Debug("服务器资源版本: " + this.ServerVersion.ResouceVersionInfo, true, 0); LoggerHelper.Debug("服务器包列表: " + this.ServerVersion.PackageList, true, 0); LoggerHelper.Debug("服务器包地址: " + this.ServerVersion.PackageUrl, true, 0); LoggerHelper.Debug("服务器Apk地址: " + this.ServerVersion.ApkUrl, true, 0); LoggerHelper.Debug("服务器md5地址: " + this.ServerVersion.PackageMd5List, true, 0); bool flag = this.ServerVersion.ProgramVersionInfo.Compare(this.LocalVersion.ProgramVersionInfo) > 0; bool flag2 = this.ServerVersion.ResouceVersionInfo.Compare(this.LocalVersion.ResouceVersionInfo) > 0; AsynResult(flag || flag2); } }; } DownloadMgr.Instance.AsynDownLoadText(SystemConfig.GetCfgInfoUrl("version"), asynResult, OnError); } else if (OnError != null) { OnError(); } }); }
public void AsynIsNetworkTimeout(Action <bool> AsynResult) { string networkUrl; if (Application.platform != RuntimePlatform.WindowsWebPlayer && File.Exists(SystemConfig.CfgPath)) { SystemConfig.LoadCfgInfo((result) => { networkUrl = SystemConfig.GetCfgInfoUrl(SystemConfig.SERVER_LIST_URL_KEY); LoggerHelper.Info("cfg exist. " + result + " networkUrl: " + networkUrl); TryAsynDownloadText(networkUrl, AsynResult); }); } else { networkUrl = Utils.LoadResource(Utils.GetFileNameWithoutExtention(SystemConfig.CFG_FILE)); TryAsynDownloadText(networkUrl, AsynResult); } }
private IEnumerator DownloadLoginMarket() { Debug.Log("DownloadLoginMarket"); LoginMarketData.dataMap.Clear(); WWW d = new WWW(SystemConfig.GetCfgInfoUrl(SystemConfig.LOGIN_MARKET_URL_KEY)); yield return(d); Debug.Log("DownloadLoginMarket d: " + d.text.Length); var xml = XMLParser.LoadXML(d.text); var map = XMLParser.LoadIntMap(xml, SystemConfig.LOGIN_MARKET_URL_KEY); var type = typeof(LoginMarketData); var props = type.GetProperties(); foreach (var item in map) { var t = new LoginMarketData(); foreach (var prop in props) { if (prop.Name == "id") { prop.SetValue(t, item.Key, null); } else { if (item.Value.ContainsKey(prop.Name)) { var value = Utils.GetValue(item.Value[prop.Name], prop.PropertyType); prop.SetValue(t, value, null); } } } if (!LoginMarketData.dataMap.ContainsKey(item.Key)) { Debug.Log("LoginMarketData new " + item.Key + " version" + t.version); LoginMarketData.dataMap.Add(item.Key, t); } } EventDispatcher.TriggerEvent(Events.OperationEvent.GetLoginMessage); }
void Start() { goDiver = gameObject; Application.targetFrameRate = 30; Screen.sleepTimeout = (int)SleepTimeout.NeverSleep; gameObject.AddComponent <LoadResources>(); var gameData = GameDataControler.Instance; if (Application.platform == RuntimePlatform.Android) { gameObject.AddComponent <PlatformMessageReceiver>(); } SystemConfig.Init((flag) => { serverIp = SystemConfig.GetCfgInfoUrl("serverlist"); gameData.Init(null, () => { MogoWorld.Init(MogoWorld.StartGame); hasInitFinish = true; }, null); }); }
public void AsynIsNetworkTimeout(Action <bool> AsynResult) { Action <bool> callback = null; string networkUrl; if (File.Exists(SystemConfig.CfgPath)) { if (callback == null) { callback = delegate(bool result) { networkUrl = SystemConfig.GetCfgInfoUrl("serverlist"); LoggerHelper.Info(string.Concat(new object[] { "cfg exist. ", result, " networkUrl: ", networkUrl }), true); this.TryAsynDownloadText(networkUrl, AsynResult); }; } SystemConfig.LoadCfgInfo(callback); } else { networkUrl = Utils.LoadResource(Utils.GetFileNameWithoutExtention("cfg.xml", '/')); this.TryAsynDownloadText(networkUrl, AsynResult); } }
public IEnumerator DownloadNotice() { string url = SystemConfig.GetCfgInfoUrl(SystemConfig.NOTICE_URL_KEY); if (url == string.Empty) { url = "http://192.168.20.107/mogo/notice.xml"; } WWW d = new WWW(url); //Debug.Log("DownloadNotice() url="+url); yield return(d); noticeXml = d.text; //Debug.Log(d.text); #if UNITY_IPHONE //use native md5 interface string md5 = IOSUtils.FormatMD5(IOSUtils.CreateMD5(d.bytes)); #else string md5 = Utils.FormatMD5(Utils.CreateMD5(d.bytes)); #endif //Debug.Log("md5:" + md5); if (SystemConfig.Instance.noticeMd5 == md5 && SystemConfig.Instance.Passport == SystemConfig.Instance.PassportSeenNotice) { yield break; } SystemConfig.Instance.noticeMd5 = md5; SystemConfig.Instance.PassportSeenNotice = SystemConfig.Instance.Passport; SystemConfig.SaveConfig(); if (DownloadFinished != null && !MogoWorld.BeginLogin)//如果开始登录了就不打开公告板 { DownloadFinished(); } IsDownloadFinished = true; }
public void BeforeCheck(Action <bool> AsynResult, Action OnError) { //阻塞,直到超时问题解决 var checkTimeout = new CheckTimeout(); checkTimeout.AsynIsNetworkTimeout((success) => { if (success) { DownloadMgr.Instance.AsynDownLoadText(SystemConfig.GetCfgInfoUrl(SystemConfig.VERSION_URL_KEY), (serverVersion) => { if (File.Exists(SystemConfig.ServerVersionPath)) //增加本地版本检查 { serverVersion = Utils.LoadFile(SystemConfig.ServerVersionPath); LoggerHelper.Info("serverVersion exist:\n" + serverVersion); } ServerVersion = GetVersionInXML(serverVersion); if (ServerVersion.IsDefault()) { if (OnError != null) { OnError(); } return; } Mogo.Util.LoggerHelper.Debug("服务器程序版本: " + ServerVersion.ProgramVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器资源版本: " + ServerVersion.ResouceVersionInfo); Mogo.Util.LoggerHelper.Debug("服务器包列表: " + ServerVersion.PackageList); Mogo.Util.LoggerHelper.Debug("服务器包地址: " + ServerVersion.PackageUrl); Mogo.Util.LoggerHelper.Debug("服务器Apk地址: " + ServerVersion.ApkUrl); Mogo.Util.LoggerHelper.Debug("服务器md5地址: " + ServerVersion.PackageMd5List); var compareProgramVersion = ServerVersion.ProgramVersionInfo.Compare(LocalVersion.ProgramVersionInfo) > 0; //服务程序版本号比本地版本号大 var compareResourceVersion = ServerVersion.ResouceVersionInfo.Compare(LocalVersion.ResouceVersionInfo) > 0; //服务器资源版本比本地高 AsynResult(compareProgramVersion || compareResourceVersion); }, OnError); } else { if (OnError != null) { OnError(); } } }); //CheckNetworkTimeout(); //var serverVersion = DownloadMgr.Instance.DownLoadText(SystemConfig.GetCfgInfoUrl(SystemConfig.VERSION_URL_KEY)); //{ // ServerVersion = GetVersionInXML(serverVersion); // Mogo.Util.LoggerHelper.Debug("服务器程序版本: " + ServerVersion.ProgramVersionInfo); // Mogo.Util.LoggerHelper.Debug("服务器资源版本: " + ServerVersion.ResouceVersionInfo); // Mogo.Util.LoggerHelper.Debug("服务器包列表: " + ServerVersion.PackageList); // Mogo.Util.LoggerHelper.Debug("服务器包地址: " + ServerVersion.PackageUrl); // Mogo.Util.LoggerHelper.Debug("服务器Apk地址: " + ServerVersion.ApkUrl); // Mogo.Util.LoggerHelper.Debug("服务器md5地址: " + ServerVersion.PackageMd5List); //} //var compareProgramVersion = ServerVersion.ProgramVersionInfo.Compare(LocalVersion.ProgramVersionInfo) > 0;//服务程序版本号比本地版本号大 //var compareResourceVersion = ServerVersion.ResouceVersionInfo.Compare(LocalVersion.ResouceVersionInfo) > 0;//服务器资源版本比本地高 //return compareProgramVersion || compareResourceVersion; }