Browse Source

接口测试

胡佳骏 1 year ago
parent
commit
e4dc81a5f9
2 changed files with 16 additions and 9 deletions
  1. 12 7
      Assets/COSScripts/COSDownLoad.cs
  2. 4 2
      Assets/COSScripts/DownloadResManager.cs

+ 12 - 7
Assets/COSScripts/COSDownLoad.cs

@@ -116,7 +116,7 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         if (jObject["code"].ToString() == "200")
         {
             sceneSuccessCos = JsonConvert.DeserializeObject<SuccessCOS>(jObject["data"].ToString());
-            InitMaterialCos();
+            InitSceneCos();
         }
         else
         {
@@ -192,10 +192,10 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
 
         // 手动设置高级下载接口的并发数 (默认为5), 从5.4.26版本开始支持!
         //downloadTask.SetMaxTasks(10);
-        //downloadTask.progressCallback = delegate (long completed, long total)
-        //{
-        //    Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
-        //};
+        downloadTask.progressCallback = delegate (long completed, long total)
+        {
+            Debug.Log(String.Format("Hjj    download"+downloadMaterial.downLoadPath+"progress = {0:##.##}%", completed * 100.0 / total));
+        };
         Debug.Log(downloadMaterial.downLoadPath);
         downloadTask.onState += OnState;
         listDownLoadTask.Add(downloadTask);
@@ -317,20 +317,25 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         Debug.Log(state);
 
         if (state == TaskState.Completed || state == TaskState.Failed)
-            for (int i = 0; i < listDownLoadTask.Count; i++)
+        {
+            int ct = listDownLoadTask.Count - 1;
+            for (int i = ct; i >= 0; i--)
             {
-                Debug.Log(listDownLoadTask.Count + "   " + listDownLoadTask[i].State() + "   " + listDownLoadTask[i].localFileName);
+                
                 if (listDownLoadTask[i].State() == TaskState.Completed)
                 {
+                    Debug.Log(listDownLoadTask.Count + "   " + listDownLoadTask[i].State() + "   " + listDownLoadTask[i].localFileName);
                     DownloadResManager.Instance.DownLoadCompleted(listDownLoadTask[i].localFileName);
                     listDownLoadTask.RemoveAt(i);
                 }
                 if (listDownLoadTask[i].State() == TaskState.Failed)
                 {
+                    Debug.Log(listDownLoadTask.Count + "   " + listDownLoadTask[i].State() + "   " + listDownLoadTask[i].localFileName);
                     DownloadResManager.Instance.DownLoadFaild(listDownLoadTask[i].localFileName);
                     listDownLoadTask.RemoveAt(i);
                 }
             }
+        }
     }
 
 }

+ 4 - 2
Assets/COSScripts/DownloadResManager.cs

@@ -149,7 +149,8 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
         nowDownLoad--;
         for (int i = 0; i < listNotMaterial.Count; i++)
         {
-            if(Path.GetFileName( listNotMaterial[i].localLoadPath) == localFilePath)
+            Debug.Log("Hjj   DownLoadCompleted :" + listNotMaterial[i].downLoadPath + "——" + localFilePath);
+            if (Path.GetFileName( listNotMaterial[i].downLoadPath) == localFilePath)
             {
                 listCompletedMaterial.Add(listNotMaterial[i]);              
                 LocalLoadManager.Instance.LocalLoadMaterial(listNotMaterial[i]);
@@ -168,7 +169,8 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
         nowDownLoad--;
         for (int i = 0; i < listNotMaterial.Count; i++)
         {
-            if (Path.GetFileName(listNotMaterial[i].localLoadPath) == localFilePath)
+            Debug.Log("Hjj   DownLoadFaild :" + listNotMaterial[i].downLoadPath + "——" + localFilePath);
+            if (Path.GetFileName(listNotMaterial[i].downLoadPath) == localFilePath)
             {
                 listFaildMaterial.Add(listNotMaterial[i]);
                 MsgHandler.SendMsg(listNotMaterial[i].localLoadPath, null);