public static VersionUpdate GetIns()
 {
     if (inst == null)
     {
         inst = new VersionUpdate();
     }
     return(inst);
 }
Example #2
0
        public bool DownLoad()
        {
            bool b = VersionUpdate.GetIns().UpdateOneRes(name, DownloadResult);

            if (b == true)
            {
                m_status = AssetLoadStatus.Downloading;
            }
            return(b);
        }
Example #3
0
        private void _AddDependAbSync(BundleInfo info)
        {
            if (info == null)
            {
                return;
            }

            //find cache
            if (info.HasDependBundle())
            {
                for (int i = 0; i < info.dependBundle.Count; ++i)
                {
                    BundleInfo dependInfo = m_assetCfg.GetBundleInfo(info.dependBundle[i]);
                    //find cache
                    BundleCache bundle = null;
                    if (!m_bundleCache.TryGetValue(dependInfo.name, out bundle))
                    {
                        //load depend
                        _AddDependAbSync(dependInfo);
                    }
                    else
                    {
                        bundle.Access();
                    }
                }
            }

            //load
            AssetBundle ab = _LoadAssetBundleSync(info.name);

            if (ab != null)
            {
                BundleCache bundle = new BundleCache();
                bundle.name   = info.name;
                bundle.info   = info;
                bundle.bundle = ab;
                bundle.Access();
                m_bundleCache.Add(info.name, bundle);
            }
            else
            {
                if (m_useDownload)
                {
                    VersionUpdate.GetIns().UpdateOneRes(info.name, null);
                }
            }
        }
Example #4
0
        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();
        }
Example #5
0
        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());
            }
        }
Example #6
0
        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();
        }