示例#1
0
 public void Download(string module, Md5File md5File)
 {
     _md5File = md5File;
     _module  = module;
     _failList.Clear();
     DownloadNext();
 }
示例#2
0
 private void DownloadMd5FileComplete(Md5File md5File)
 {
     _tempQueue = new Queue <SDownloadModuleConfig>(md5File.DownloadQueue);
     if (_tempQueue == null || !_isGetSize)
     {
         if (_complete != null)
         {
             _complete(md5File, 0);
         }
         return;
     }
     GetNext(md5File);
 }
示例#3
0
        private void DownloadCompleted(WWW www)
        {
            if (www == null)
            {
                if (_failRetryCount <= 0)
                {
                    _onCompleted(null);
                    return;
                }
                _failRetryCount--;
                StartDownload(_failRetryDelay);
                return;
            }
            Md5File md5File = new Md5File(_module, www.text);

            if (_onCompleted != null)
            {
                _onCompleted(md5File);
            }
        }
示例#4
0
        public void CheckUpdate(CheckUpdateTable table, bool isGetSize)
        {
            //编辑器模式模拟检查完成
            if (GameConfig.gameModel == GameModel.Editor)
            {
                if (table != null && table.Complete != null)
                {
                    table.Complete(Name, 0, string.Empty);
                    return;
                }
            }
            CheckUpdateBehaviour cub = new GameObject(Name + "_CheckUpdateBehaviour").AddComponent <CheckUpdateBehaviour>();

            cub.CheckUpdate(Name, isGetSize, (Md5File md5File, long size) =>
            {
                _size          = size;
                _md5File       = md5File;
                _downloadQueue = md5File.DownloadQueue;
                _sizeStr       = Util.HumanReadableFilesize(Convert.ToDouble(_size));
                if (table == null)
                {
                    return;
                }
                if (_downloadQueue == null)
                {
                    Debug.LogError(string.Format("{0}:检查更新失败!", Name));
                    if (table.Error != null)
                    {
                        table.Error(Name);
                    }
                    return;
                }
                Debug.Log(Name + " 需要下载 " + _sizeStr);
                if (table.Complete != null)
                {
                    table.Complete(Name, _downloadQueue.Count, _sizeStr);
                }
                Destroy(cub.gameObject);
                cub = null;
            });
        }
示例#5
0
        private void GetNext(Md5File md5File)
        {
            if (_tempQueue.Count == 0)
            {
                if (_complete != null)
                {
                    _complete(md5File, _size);
                }
                return;
            }
            SDownloadModuleConfig download = _tempQueue.Dequeue();

            _webDownload.DownloadFileSize(download.download_url, TIMEOUT, (bool ok, int code, int size) =>
            {
                if (ok)
                {
                    _size += size;
                }
                //Debug.Log(download.download_url + "  ok:" + ok + " code:" + code + " size:" + size+"         "+ _downloadQueue.Count);
                GetNext(md5File);
            });
        }