public void Update(float elapseSeconds, float readElapseSeconds) { if (m_UpdateAllowed) { if (m_UpdateWaitingInfo.Count > 0) { if (m_DownloadManager.FreeAgentCount > 0) { UpdateInfo updateInfo = m_UpdateWaitingInfo[0]; m_UpdateWaitingInfo.RemoveAt(0); m_DownloadManager.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(m_ResourceManager.m_UpdatePrefixUri, Utility.Path.GetResourceNameWithCrc32AndSuffix(updateInfo.ResourceName.FullName, updateInfo.HashCode)), updateInfo); m_UpdatingCount++; } } else if (m_UpdatingCount <= 0) { m_UpdateAllowed = false; Utility.Path.RemoveEmptyDirectory(m_ResourceManager.m_ReadWritePath); if (ResourceUpdateAllComplete != null) { ResourceUpdateAllComplete(UpdateFailureCount <= 0); } } } }
/// <summary> /// 资源更新器轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_UpdateAllowed && !m_UpdateComplete) { if (m_UpdateWaitingInfo.Count > 0) { if (m_DownloadManager.FreeAgentCount > 0) { UpdateInfo updateInfo = m_UpdateWaitingInfo[0]; m_UpdateWaitingInfo.RemoveAt(0); m_DownloadManager.AddDownload(updateInfo.DownloadPath, updateInfo.DownloadUri, updateInfo); m_UpdatingCount++; } } else if (m_UpdatingCount <= 0) { m_UpdateComplete = true; Utility.Path.RemoveEmptyDirectory(m_ResourceManager.m_ReadWritePath); if (ResourceUpdateAllComplete != null) { ResourceUpdateAllComplete(); } } } }
/// <summary> /// 资源更新器轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_UpdateWaitingInfo.Count > 0) { if (m_DownloadManager.FreeAgentCount > 0) { UpdateInfo updateInfo = m_UpdateWaitingInfo[0]; m_UpdateWaitingInfo.RemoveAt(0); string resourceFullNameWithCrc32 = updateInfo.ResourceName.Variant != null?Utility.Text.Format("{0}.{1}.{2:x8}.{3}", updateInfo.ResourceName.Name, updateInfo.ResourceName.Variant, updateInfo.HashCode, DefaultExtension) : Utility.Text.Format("{0}.{1:x8}.{2}", updateInfo.ResourceName.Name, updateInfo.HashCode, DefaultExtension); m_DownloadManager.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, resourceFullNameWithCrc32)), updateInfo); m_UpdatingCount++; } return; } if (m_UpdatingResourceGroup != null && m_UpdatingCount <= 0) { ResourceGroup updatingResourceGroup = m_UpdatingResourceGroup; m_UpdatingResourceGroup = null; if (ResourceUpdateAllComplete != null) { ResourceUpdateAllComplete(updatingResourceGroup, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0); } } }
/// <summary> /// 资源更新器轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_UpdatingResourceGroup == null) { return; } if (m_UpdateWaitingInfo.Count > 0) { if (m_DownloadManager.FreeAgentCount > 0) { UpdateInfo updateInfo = m_UpdateWaitingInfo[0]; m_UpdateWaitingInfo.RemoveAt(0); m_DownloadManager.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, Utility.Path.GetResourceNameWithCrc32AndSuffix(updateInfo.ResourceName.FullName, updateInfo.HashCode))), updateInfo); m_UpdatingCount++; } } else if (m_UpdatingCount <= 0) { ResourceGroup updatingResourceGroup = m_UpdatingResourceGroup; m_UpdatingResourceGroup = null; Utility.Path.RemoveEmptyDirectory(m_ResourceManager.m_ReadWritePath); if (ResourceUpdateAllComplete != null) { ResourceUpdateAllComplete(updatingResourceGroup, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0); } } }
/// <summary> /// Adds the selected video to the downloads. /// </summary> private void OnAddDownload() { var downloadItem = _composer.GetExportedValue <IDownloadItem>(); downloadItem.RssItem = SelectedVideo; _downloadManager.AddDownload(downloadItem); }
public void UpdateVersionList(int versionListLength, int versionListHashCode) { m_VersionListLength = versionListLength; m_VersionListHashCode = versionListHashCode; string versionListFileName = Utility.Path.GetResourceNameWithSuffix(VersionListName); m_DownloadManager.AddDownload(localVersionListFilePath); }
/// <summary> /// 资源更新器轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_ApplyingResourcePackStream != null) { while (m_ApplyWaitingInfo.Count > 0) { ApplyInfo applyInfo = m_ApplyWaitingInfo[0]; m_ApplyWaitingInfo.RemoveAt(0); if (ApplyResource(applyInfo)) { return; } } Array.Clear(m_CachedBytes, 0, CachedBytesLength); string resourcePackPath = m_ApplyingResourcePackPath; m_ApplyingResourcePackPath = null; m_ApplyingResourcePackStream.Dispose(); m_ApplyingResourcePackStream = null; if (ResourceApplyComplete != null) { ResourceApplyComplete(resourcePackPath, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0); } } if (m_UpdateWaitingInfo.Count > 0) { if (m_DownloadManager.FreeAgentCount > 0) { UpdateInfo updateInfo = m_UpdateWaitingInfo[0]; m_UpdateWaitingInfo.RemoveAt(0); string resourceFullNameWithCrc32 = updateInfo.ResourceName.Variant != null?Utility.Text.Format("{0}.{1}.{2:x8}.{3}", updateInfo.ResourceName.Name, updateInfo.ResourceName.Variant, updateInfo.HashCode, DefaultExtension) : Utility.Text.Format("{0}.{1:x8}.{2}", updateInfo.ResourceName.Name, updateInfo.HashCode, DefaultExtension); m_DownloadManager.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, resourceFullNameWithCrc32)), updateInfo); m_UpdatingCount++; } return; } if (m_UpdatingResourceGroup != null && m_UpdatingCount <= 0) { ResourceGroup updatingResourceGroup = m_UpdatingResourceGroup; m_UpdatingResourceGroup = null; if (ResourceUpdateComplete != null) { ResourceUpdateComplete(updatingResourceGroup, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0); } return; } }
private bool DownloadResource(UpdateInfo updateInfo) { if (updateInfo.Downloading) { return(false); } updateInfo.Downloading = true; string resourceFullNameWithCrc32 = updateInfo.ResourceName.Variant != null?Utility.Text.Format("{0}.{1}.{2:x8}.{3}", updateInfo.ResourceName.Name, updateInfo.ResourceName.Variant, updateInfo.HashCode, DefaultExtension) : Utility.Text.Format("{0}.{1:x8}.{2}", updateInfo.ResourceName.Name, updateInfo.HashCode, DefaultExtension); m_DownloadManager.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, resourceFullNameWithCrc32)), updateInfo); return(true); }
public void DownloadFile(string url, string fileName) { if (url == null) { throw new ArgumentNullException(nameof(url)); } if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } Uri resource = new Uri(url, UriKind.Absolute); RunUsingScheduler(uiScheduler, () => downloadManager.AddDownload(resource, fileName)).Wait(); }
/// <summary> /// For each Manifest recorded, try re downloading the incomplete ones /// </summary> public void Restore() { for (int i = 0; i < _IDList.Count(); i++) { Manifest m = _IDList.Get(i); if ((m.Status == Manifest.StatusFlags.Failed) || (m.Status == Manifest.StatusFlags.Downloading) || (m.Status == Manifest.StatusFlags.Queued) || (m.Status == Manifest.StatusFlags.None)) { Manifest oldManifest = m; _Manager.AddDownload(m); if (m != oldManifest) { throw new System.Exception("DownloadLedger: This shouldn't happen. There was probably a mix of ledger and non ledger downloads. Currently unhandled"); } } } }
/// <summary> /// 更新版本资源列表。 /// </summary> /// <param name="versionListLength">版本资源列表大小。</param> /// <param name="versionListHashCode">版本资源列表哈希值。</param> /// <param name="versionListCompressedLength">版本资源列表压缩后大小。</param> /// <param name="versionListCompressedHashCode">版本资源列表压缩后哈希值。</param> public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode) { if (m_DownloadManager == null) { throw new GameFrameworkException("You must set download manager first."); } m_VersionListLength = versionListLength; m_VersionListHashCode = versionListHashCode; m_VersionListCompressedLength = versionListCompressedLength; m_VersionListCompressedHashCode = versionListCompressedHashCode; string localVersionListFilePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceManager.m_ReadWritePath, RemoteVersionListFileName)); int dotPosition = RemoteVersionListFileName.LastIndexOf('.'); string latestVersionListFullNameWithCrc32 = Utility.Text.Format("{0}.{2:x8}.{1}", RemoteVersionListFileName.Substring(0, dotPosition), RemoteVersionListFileName.Substring(dotPosition + 1), m_VersionListHashCode); m_DownloadManager.AddDownload(localVersionListFilePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_UpdatePrefixUri, latestVersionListFullNameWithCrc32)), DownloadTag, this); }
/// <summary> /// 更新版本资源列表。 /// </summary> /// <param name="versionListLength">版本资源列表大小。</param> /// <param name="versionListHashCode">版本资源列表哈希值。</param> /// <param name="versionListZipLength">版本资源列表压缩后大小。</param> /// <param name="versionListZipHashCode">版本资源列表压缩后哈希值。</param> public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListZipLength, int versionListZipHashCode) { if (m_DownloadManager == null) { throw new GameFrameworkException("You must set download manager first."); } m_VersionListLength = versionListLength; m_VersionListHashCode = versionListHashCode; m_VersionListZipLength = versionListZipLength; m_VersionListZipHashCode = versionListZipHashCode; string versionListFileName = Utility.Path.GetResourceNameWithSuffix(VersionListFileName); string latestVersionListFileName = Utility.Path.GetResourceNameWithCrc32AndSuffix(VersionListFileName, versionListHashCode); string localVersionListFilePath = Utility.Path.GetCombinePath(m_ResourceManager.m_ReadWritePath, versionListFileName); string latestVersionListFileUri = Utility.Path.GetRemotePath(m_ResourceManager.m_UpdatePrefixUri, latestVersionListFileName); m_DownloadManager.AddDownload(localVersionListFilePath, latestVersionListFileUri, this); }
/// <summary> /// 增加下载任务。 /// </summary> /// <param name="downloadPath">下载后存放路径。</param> /// <param name="downloadUri">原始下载地址。</param> /// <returns>新增下载任务的序列编号。</returns> public int AddDownload(string downloadPath, string downloadUri) { return(m_DownloadManager.AddDownload(downloadPath, downloadUri)); }
/// <summary> /// 增加下载任务。 /// </summary> /// <param name="downloadPath">下载后存放路径。</param> /// <param name="downloadUri">原始下载地址。</param> /// <param name="tag">下载任务的标签。</param> /// <param name="priority">下载任务的优先级。</param> /// <param name="userData">用户自定义数据。</param> /// <returns>新增下载任务的序列编号。</returns> public int AddDownload(string downloadPath, string downloadUri, string tag, int priority, object userData) { return(m_DownloadManager.AddDownload(downloadPath, downloadUri, tag, priority, userData)); }
/// <summary> /// 增加下载任务 /// </summary> /// <param name="downloadPath">下载后存放路径</param> /// <param name="downloadUri">原始下载地址</param> /// <param name="userData">用户自定义数据</param> /// <returns>新增下载任务的序列编号</returns> public int AddDownload(string downloadPath, string downloadUri, object userData = null) { return(m_DownloadManager.AddDownload(downloadPath, downloadUri, userData)); }