public void WebRequestSuccessHandle(DownLoadFileUnit downLoadFileUnit, bool isErro, DownWebRequestItem item) { if (!isErro) { item.Destroy(); curReconnectionCount = 0; this.successSize += downLoadFileUnit.Length; if (OneFileDownloadSuccess != null) { OneFileDownloadSuccess(downLoadFileUnit); } if (!IsSuccess()) { Check(); return; } if (WebRequestSuccess != null) { WebRequestSuccess(downLoadFileUnit); } } else { item.Reconnection(); } }
/// <summary> /// 检测需要下载的资源 /// </summary> //public void OnCheckUpdateOnLineFile(out List<DownLoadFileUnit> m_downLoadList, out long m_downloadSize) //{ // string downfileUrl = GameUserMode.GetServerResUrl() + "{0}?v=" + serverGameVersionInfo.version; // //long // m_downLoadList = new List<jmz.DownLoadFileUnit>(); // m_downloadSize = 0; // if (localGameVersionInfo == null) // { // //下载 allgame.zip // if (serverGameVersionInfo.allpack != null && serverGameVersionInfo.allpack.Length > 0) // { // m_downloadSize += serverGameVersionInfo.allsize; // m_downLoadList.Add(new jmz.DownLoadFileUnit( // string.Format(downfileUrl, serverGameVersionInfo.allpack), // serverGameVersionInfo.allpack, // GameDownloadManager.Init_Res_Group, // Util.DataPath + serverGameVersionInfo.allpack, // "", // serverGameVersionInfo.allsize, // "zip")); // return; // } // } // for (int j = 0; j < serverGameVersionInfo.files.Count; j++) // { // GameVersionInfo.FilesAttribute file = serverGameVersionInfo.files[j]; // bool nofile = true; // if (localGameVersionInfo != null) // { // for (int i = 0; i < localGameVersionInfo.files.Count; i++) // { // GameVersionInfo.FilesAttribute f = localGameVersionInfo.files[i]; // if (f.name.Equals(file.name)) // { // nofile = false; // if (f.md5.Equals(file.md5) == false) // { // m_downloadSize += file.size; // m_downLoadList.Add(new jmz.DownLoadFileUnit( // string.Format(downfileUrl, file.name), // file.name, // GameDownloadManager.Init_Res_Group, // Util.DataPath + file.name, // file.md5, // file.size, // "")); // } // break; // } // } // } // if (nofile) // { // m_downloadSize += file.size; // m_downLoadList.Add(new jmz.DownLoadFileUnit( // string.Format(downfileUrl, file.name), // file.name, // GameDownloadManager.Init_Res_Group, // Util.DataPath + file.name, // file.md5, // file.size, // "")); // } // } //} /// <summary> /// 更新场景资源 /// </summary> //public void OnCheckUpateHallFile(out List<DownLoadFileUnit> m_downLoadList, out long m_downloadSize) //{ // string downfileUrl = GameUserMode.GetServerResUrl() + "{0}?v=" + serverGameVersionInfo.version; // //long // m_downLoadList = new List<jmz.DownLoadFileUnit>(); // m_downloadSize = 0; // for (int j = 0; j < serverGameVersionInfo.exafiles.Count; j++) // { // GameVersionInfo.FilesAttribute file = serverGameVersionInfo.exafiles[j]; // bool nofile = true; // if (localGameVersionInfo != null) // { // for (int i = 0; i < localGameVersionInfo.files.Count; i++) // { // GameVersionInfo.FilesAttribute f = localGameVersionInfo.files[i]; // if (f.name.Equals(file.name)) // { // nofile = false; // if (f.md5.Equals(file.md5) == false) // { // m_downloadSize += file.size; // m_downLoadList.Add(new jmz.DownLoadFileUnit( // string.Format(downfileUrl, file.name), // f.name, // GameDownloadManager.Hall_Res_Group, // Util.DataPath + file.name, // file.md5, // file.size, // "")); // } // break; // } // } // } // if (nofile) // { // m_downloadSize += file.size; // m_downLoadList.Add(new jmz.DownLoadFileUnit( // string.Format(downfileUrl, file.name), // file.name, // GameDownloadManager.Hall_Res_Group, // Util.DataPath + file.name, // file.md5, // file.size, // "")); // } // } //} public void UpdateLocalFiles(DownLoadFileUnit file) { lock (sLock) { //if (localGameVersionInfo == null) //{ // localGameVersionInfo = new GameVersionInfo(); //} //localGameVersionInfo.OnChangeFileAttr(new GameVersionInfo.FilesAttribute(file.FileName, file.Hash, file.Length)); OnSaveFilesInfo(); } }
public void Check() { for (int i = lastWebRequestIndex; lastWebRequestIndex < webRequestList.Count; i++, lastWebRequestIndex++) { if (!CheckFreeWebRequest()) { return; } DownLoadFileUnit downLoadUnit = webRequestList[lastWebRequestIndex]; Request(downLoadUnit); } }
public bool Request(DownLoadFileUnit downLoadFileUnit) { if (string.IsNullOrEmpty(downLoadFileUnit.DownLoadUrl)) { return(false); } if (string.IsNullOrEmpty(downLoadFileUnit.FilePath)) { return(false); } if (!CheckFreeWebRequest()) { return(false); } DownWebRequestItem webRequest = GetFreeReqItem(); webRequest.Send(downLoadFileUnit); return(true); }
public void Send(DownLoadFileUnit downLoadFileUnit) { this.downLoadFileUnit = downLoadFileUnit; mono.StartCoroutine(StartDownload(downLoadFileUnit.DownLoadUrl)); }