// Token: 0x060001D6 RID: 470 RVA: 0x00009C3C File Offset: 0x00007E3C private static List <AudioManager4CRI.FileInfo> DifferentiateFileInfos(List <AudioManager4CRI.FileInfo> serverInfos, List <AudioManager4CRI.FileInfo> clientInfos, List <AudioManager4CRI.FileInfo> cacheInfos) { List <AudioManager4CRI.FileInfo> list = new List <AudioManager4CRI.FileInfo>(); if (serverInfos == null || clientInfos == null) { return(list); } for (int j = 0; j < serverInfos.Count; j++) { AudioManager4CRI.FileInfo i = serverInfos[j]; if (!i.m_path.Contains("AllFilesPath.txt")) { if (!clientInfos.Exists((AudioManager4CRI.FileInfo info) => info.m_path == i.m_path && info.m_md5 == i.m_md5)) { i.m_isAtClient = false; serverInfos[j] = i; if (cacheInfos == null || !cacheInfos.Exists((AudioManager4CRI.FileInfo info) => info.m_path == i.m_path && info.m_md5 == i.m_md5)) { list.Add(i); } } } } return(list); }
// Token: 0x060001D5 RID: 469 RVA: 0x00009C10 File Offset: 0x00007E10 private static IEnumerator DownloadAudioFileToCache(AudioManager4CRI.FileInfo fi, Action <bool> onEnd, Action <WWW> onUpdate = null) { byte[] fileData = null; yield return(Util.DownloadHttpFile(string.Format("{0}/{1}", AudioManager4CRI.DownloadUrlRoot, fi.m_path), delegate(bool ret, WWW www) { if (!ret) { if (onEnd != null) { onEnd(ret); } return; } fileData = www.bytes; }, onUpdate)); if (fileData == null) { onEnd(false); yield break; } try { string path = string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, fi.m_path); string directoryName = Path.GetDirectoryName(path); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllBytes(path, fileData); int num = AudioManager4CRI.m_cacheCriAssetFileInfos.FindIndex((AudioManager4CRI.FileInfo info) => fi.m_path == info.m_path); if (num >= 0) { AudioManager4CRI.m_cacheCriAssetFileInfos.RemoveAt(num); } AudioManager4CRI.m_cacheCriAssetFileInfos.Add(fi); } catch (Exception ex) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFileToCache exception: " + ex.Message); onEnd(false); yield break; } if (onEnd != null) { onEnd(true); } yield break; }
// Token: 0x060001D2 RID: 466 RVA: 0x00009AC0 File Offset: 0x00007CC0 public static IEnumerator DownloadAudioFiles(Action <bool> onEnd, Action <long, long> onUpdate = null, Action <long> onEndAfterGotDownloadLength = null, MonoBehaviour coroutineOwner = null) { if (GameManager.Instance == null || GameManager.Instance.GameClientSetting == null) { yield break; } if (!GameManager.Instance.GameClientSetting.AudioSetting.EnableDownload) { yield break; } if (!AudioManager4CRI.LoadAllFilesPaths()) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles Failed to LoadAllFilesPaths()."); yield break; } bool isSuccess = false; string serverFileListMd5 = string.Empty; yield return(Util.DownloadHttpFile(string.Format("{0}/{1}", AudioManager4CRI.DownloadUrlRoot, "AllFilesPath.txt.md5"), delegate(bool ret, WWW www) { isSuccess = ret; if (ret) { serverFileListMd5 = www.text; } }, null)); if (!isSuccess) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles download filelist's md5 Failed ."); if (onEnd != null) { onEnd(false); } yield break; } string localFileListMd5 = AudioManager4CRI.LoadTextFile(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt.md5")); if (string.IsNullOrEmpty(localFileListMd5) || localFileListMd5 != serverFileListMd5) { yield return(Util.DownloadHttpFile(string.Format("{0}/{1}", AudioManager4CRI.DownloadUrlRoot, "AllFilesPath.txt"), delegate(bool ret, WWW www) { isSuccess = ret; if (ret) { try { if (!Directory.Exists(AudioManager4CRI.CacheFolderPath)) { Directory.CreateDirectory(AudioManager4CRI.CacheFolderPath); } File.WriteAllText(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt"), www.text); File.WriteAllText(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt.md5"), serverFileListMd5); } catch (Exception ex) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles exception: {0}", ex.Message)); isSuccess = false; } } }, null)); if (!isSuccess) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles download filelist Failed ."); if (onEnd != null) { onEnd(false); } yield break; } } AudioManager4CRI.m_serverCriAssetFileInfos = AudioManager4CRI.LoadFileInfos(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt")); AudioManager4CRI.m_cacheCriAssetFileInfos = AudioManager4CRI.LoadFileInfos(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt")); List <AudioManager4CRI.FileInfo> differentFileInfos = AudioManager4CRI.DifferentiateFileInfos(AudioManager4CRI.m_serverCriAssetFileInfos, AudioManager4CRI.m_clientCriAssetFileInfos, AudioManager4CRI.m_cacheCriAssetFileInfos); long totalDownloadLength = AudioManager4CRI.GetTotalFileLengh(differentFileInfos); if (onEndAfterGotDownloadLength != null) { onEndAfterGotDownloadLength(totalDownloadLength); yield break; } long downloadedLength = 0L; if (coroutineOwner == null || coroutineOwner.gameObject == null || !coroutineOwner.gameObject.activeInHierarchy) { using (List <AudioManager4CRI.FileInfo> .Enumerator enumerator = differentFileInfos.GetEnumerator()) { while (enumerator.MoveNext()) { AudioManager4CRI.FileInfo i = enumerator.Current; yield return(AudioManager4CRI.DownloadAudioFileToCache(i, delegate(bool ret) { if (!ret) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles download audio file {0} Failed .", i.m_path)); isSuccess = false; } else { downloadedLength += i.m_length; } if (!AudioManager4CRI.SaveFileInfos(Path.Combine(AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt"), AudioManager4CRI.m_cacheCriAssetFileInfos)) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles save cache filelist Failed ."); isSuccess = false; } }, delegate(WWW www) { if (onUpdate != null) { onUpdate(downloadedLength + (long)www.bytesDownloaded, totalDownloadLength); } })); } } } else { int downloadCoroutinCount = 0; HashSet <WWW> runningWWW = new HashSet <WWW>(); using (List <AudioManager4CRI.FileInfo> .Enumerator enumerator2 = differentFileInfos.GetEnumerator()) { while (enumerator2.MoveNext()) { AudioManager4CRI.FileInfo i = enumerator2.Current; yield return(new WaitUntil(() => downloadCoroutinCount < 4)); downloadCoroutinCount++; coroutineOwner.StartCoroutine(AudioManager4CRI.DownloadAudioFileToCache(i, delegate(bool ret) { if (!ret) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles download audio file {0} Failed .", i.m_path)); isSuccess = false; } else { downloadedLength += i.m_length; } if (!AudioManager4CRI.SaveFileInfos(Path.Combine(AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt"), AudioManager4CRI.m_cacheCriAssetFileInfos)) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles save cache filelist Failed ."); isSuccess = false; } downloadCoroutinCount--; }, delegate(WWW www) { if (!runningWWW.Contains(www) && !www.isDone) { runningWWW.Add(www); } long num = 0L; foreach (WWW www2 in runningWWW) { num += (long)www2.bytesDownloaded; } if (onUpdate != null) { onUpdate(downloadedLength + num, totalDownloadLength); } if (runningWWW.Contains(www) && www.isDone) { runningWWW.Remove(www); } })); } } yield return(new WaitUntil(() => downloadCoroutinCount == 0)); } if (!isSuccess) { if (onEnd != null) { onEnd(false); } yield break; } if (onEnd != null) { onEnd(true); } yield break; }