private void OnDownloadStart(object sender, DownloadStartEventArgs e)
            {
                UpdateInfo updateInfo = e.UserData as UpdateInfo;

                if (updateInfo == null)
                {
                    return;
                }

                if (m_DownloadManager == null)
                {
                    throw new GameFrameworkException("You must set download manager first.");
                }

                if (e.CurrentLength > updateInfo.ZipLength)
                {
                    m_DownloadManager.RemoveDownload(e.SerialId);
                    string downloadFile = Utility.Text.Format("{0}.download", e.DownloadPath);
                    if (File.Exists(downloadFile))
                    {
                        File.Delete(downloadFile);
                    }

                    string errorMessage = Utility.Text.Format("When download start, downloaded length is larger than zip length, need '{0}', current '{1}'.", updateInfo.ZipLength.ToString(), e.CurrentLength.ToString());
                    OnDownloadFailure(this, new DownloadFailureEventArgs(e.SerialId, e.DownloadPath, e.DownloadUri, errorMessage, e.UserData));
                    return;
                }

                if (ResourceUpdateStart != null)
                {
                    ResourceUpdateStart(updateInfo.ResourceName, e.DownloadPath, e.DownloadUri, e.CurrentLength, updateInfo.ZipLength, updateInfo.RetryCount);
                }
            }
Exemplo n.º 2
0
 /// <summary>
 /// 创建下载开始事件。
 /// </summary>
 /// <param name="serialId">下载任务的序列编号。</param>
 /// <param name="downloadPath">下载后存放路径。</param>
 /// <param name="downloadUri">下载地址。</param>
 /// <param name="currentLength">当前大小。</param>
 /// <param name="userData">用户自定义数据。</param>
 /// <returns>创建的下载开始事件。</returns>
 public static DownloadStartEventArgs Create(int serialId, string downloadPath, string downloadUri, int currentLength, object userData)
 {
     DownloadStartEventArgs downloadStartEventArgs = ReferencePool.Acquire<DownloadStartEventArgs>();
     downloadStartEventArgs.SerialId = serialId;
     downloadStartEventArgs.DownloadPath = downloadPath;
     downloadStartEventArgs.DownloadUri = downloadUri;
     downloadStartEventArgs.CurrentLength = currentLength;
     downloadStartEventArgs.UserData = userData;
     return downloadStartEventArgs;
 }
Exemplo n.º 3
0
        private void OnDownloadStart(object sender, DownloadStartEventArgs e)
        {
            UpdateInfo updateInfo = e.UserData as UpdateInfo;

            if (updateInfo == null)
            {
                return;
            }

            if (m_DownloadComponent == null)
            {
                throw new Exception("You must set download manager first.");
            }

            m_ResourceComponent.OnUpdaterResourceUpdateStart(updateInfo.ResourceName, e.DownloadPath, e.DownloadUri, e.CurrentLength, updateInfo.ZipLength, updateInfo.RetryCount);
        }
            private void OnDownloadStart(object sender, DownloadStartEventArgs e)
            {
                UpdateInfo updateInfo = e.UserData as updateInfo;

                if (e.CurrentLength > updateInfo.ZipLength)
                {
                    m_DownloadManager.RemoveDownload(e.Serialid);
                    string downloadFile = string.Format("{0}.download", e.DownloadPath);
                    if (File.Exists(downloadFile))
                    {
                        File.Delete(downloadFile);
                    }
                }

                ResourceUpdateStart(updateInfo.ResourceName, e.DownloadPath);
            }
Exemplo n.º 5
0
            private void OnDownloadStart(object sender, DownloadStartEventArgs e)
            {
                UpdateInfo updateInfo = e.UserData as UpdateInfo;

                if (updateInfo == null)
                {
                    return;
                }

                if (m_DownloadManager == null)
                {
                    throw new GameFrameworkException("You must set download manager first.");
                }

                if (e.CurrentLength > int.MaxValue)
                {
                    throw new GameFrameworkException(Utility.Text.Format("File '{0}' is too large.", e.DownloadPath));
                }

                if (ResourceUpdateStart != null)
                {
                    ResourceUpdateStart(updateInfo.ResourceName, e.DownloadPath, e.DownloadUri, (int)e.CurrentLength, updateInfo.CompressedLength, updateInfo.RetryCount);
                }
            }
Exemplo n.º 6
0
 private void OnDownloadStart(object sender, DownloadStartEventArgs e)
 {
     EventComponent.This.Fire(this, OuterDownloadStartEventArgs.Create(e));
 }
Exemplo n.º 7
0
 private void OnDownloadStart(object sender, DownloadStartEventArgs e)
 {
     Debug.Log("开始下载");
     //m_EventComponent.Fire(this, DownloadStartEventArgs.Create(e));
 }
 private void ThreadWatcher_DownloadStart(ThreadWatcher watcher, DownloadStartEventArgs args)
 {
     DownloadProgressInfo info = new DownloadProgressInfo();
     info.DownloadID = args.DownloadID;
     info.URL = args.URL;
     info.TryNumber = args.TryNumber;
     info.StartTicks = TickCount.Now;
     info.TotalSize = args.TotalSize;
     lock (_downloadProgresses) {
         _downloadProgresses[args.DownloadID] = info;
         ConcurrentDownloads += 1;
     }
 }
Exemplo n.º 9
0
 private static void ShowStart(object sender, DownloadStartEventArgs e)
 {
     Console.WriteLine((sender as Crawler).Name + "开始下载" + e.Url);
 }
    private void OnDownloadStart(object sender, GlobalEventArgs e)
    {
        DownloadStartEventArgs de = (DownloadStartEventArgs)e;

        Debug.Log("下载开始了:" + de.DownloadUri);
    }