public bool UpdateOneRes(string name, Action <string, bool> cb) { for (int i = 0; i < m_verRes.versionResFile.Count; ++i) { if (m_verRes.versionResFile[i].name.Equals(name)) { //不用校验了,启动游戏的时候已经全量校验过了 DownloadMgr.GetInst().CreateTask(m_verRes.versionResFile[i].name, m_verRes.versionResFile[i].signature, cb); return(true); } } return(false); }
void DoCheck() { string verFile = PathUtils.GetVaildFullPath("version.json"); m_verRes = SerializeHelper.LoadFromFile <VersionRes>(verFile); //这个大版本要写在程序里,才能保证获取的本地当前版本是对的!!! string[] programVersion = VersionResDef.version.Split('.'); string[] oldVersion = VersionUpdate.GetIns().GetVersion().Split('.'); string[] newVersion = m_verRes.version.Split('.'); string[] miniVersion = m_verRes.miniVersion.Split('.'); //强制更新apk,ios if (int.Parse(programVersion[0]) < int.Parse(miniVersion[0]) || int.Parse(programVersion[1]) < int.Parse(miniVersion[1]) ) { if (Application.platform == RuntimePlatform.Android) { DownloadMgr.GetInst().CreateTask(m_verRes.apk, m_verRes.apkSignature, DownloadApkResult); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { //todo... } else { //todo... } return; } int oldBigVersion = int.Parse(programVersion[0]); int newBigVersion = int.Parse(newVersion[0]); if (newBigVersion > oldBigVersion) { //todo...可选更新apk,ios } VersionUpdate.GetIns().SetVersion(m_verRes); m_mgr.ChangeNextStatus(); }
public override void OnEnter(Status oldStatus) { LogUtils.Log("enter app channel status"); verAddrCfg.item.Clear(); try { Uri requestUrl = new Uri("http://10.0.0.252:8080/channel_cfg/channel_ver_addr.json"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl); request.Timeout = 2000; HttpWebResponse respone = (HttpWebResponse)request.GetResponse(); long blockSize = respone.ContentLength; byte[] blockBuff = new byte[blockSize]; var respStream = respone.GetResponseStream(); int rec = respStream.Read(blockBuff, 0, (int)blockSize); respone.Close(); request.Abort(); string str = System.Text.Encoding.Default.GetString(blockBuff); verAddrCfg = JsonUtility.FromJson <ChannelVerAddrCfg>(str); int channelId = VersionUpdate.GetIns().GetChannelID(); for (int i = 0; i < verAddrCfg.item.Count; ++i) { if (verAddrCfg.item[i].id == channelId) { DownloadMgr.GetInst().SetBaseURL(verAddrCfg.item[i].addr); m_mgr.ChangeNextStatus(); return; } } LogUtils.LogError("can not find channel ver addr!"); } catch (System.Exception ex) { LogUtils.LogError(ex.ToString()); } }
public override void OnEnter(Status oldStatus) { LogUtils.Log("enter res file check and update status"); //check VersionRes verRes = VersionUpdate.GetIns().GetVersionRes(); DownloadMgr.GetInst().SetBaseURL(verRes.url); DownloadMgr.GetInst().SetMaxTaskNum(3); m_downloadFile.Clear(); m_downloadSuccFile.Clear(); for (int i = 0; i < verRes.versionResFile.Count; ++i) { VersionResFile resFile = verRes.versionResFile[i]; if (resFile.resType == VersionResType.PreDownload) { string fullPath = PathUtils.GetVaildFullPath(resFile.name); if (fullPath.Length == 0 || !FileChecker.VerifyFileSignature(fullPath, resFile.signature)) { m_downloadFile.Add(resFile.name); DownloadMgr.GetInst().CreateTask(resFile.name, verRes.versionResFile[i].signature, DownloadResult); } } else { string fileName = PathUtils.GetPersistentPath() + resFile.name; if (fileName.Length > 0 && File.Exists(fileName)) { if (!FileChecker.VerifyFileSignature(fileName, resFile.signature)) { File.Delete(fileName); } } } } CheckFinish(); }
public void Init() { m_statusMgr.RegisterStatus(new AppChannelStatus()); m_statusMgr.RegisterStatus(new GameVersionStatus()); m_statusMgr.RegisterStatus(new ResDownloadStatus()); m_statusMgr.RegisterStatus(new GameStatus()); DownloadMgr.GetInst().Init(); m_statusMgr.Init(); string verFile = PathUtils.GetVaildFullPath("version.json"); if (verFile.Length > 0) { m_verRes = SerializeHelper.LoadFromFile <VersionRes>(verFile); } if (m_verRes == null) { LogUtils.LogError("verFile can not find!"); return; } }
public void Update() { DownloadMgr.GetInst().Update(); m_statusMgr.Update(); }
public void UnInit() { DownloadMgr.GetInst().Uninit(); m_statusMgr.Uninit(); }
public override void OnExit(Status newStatus) { DownloadMgr.GetInst().StopAllTask(); }
public override void OnEnter(Status oldStatus) { LogUtils.Log("enter get version info status"); //string timeNow = System.DateTime.Now.ToLocalTime().ToString(); DownloadMgr.GetInst().CreateTask("version.json", "", DownloadResult); }