Jelajahi Sumber

下载逻辑搬运到主线程

胡佳骏 1 tahun lalu
induk
melakukan
e734c993a7
1 mengubah file dengan 19 tambahan dan 3 penghapusan
  1. 19 3
      Assets/Game/Blue/Controller/LangChaoRommMinIo.cs

+ 19 - 3
Assets/Game/Blue/Controller/LangChaoRommMinIo.cs

@@ -58,6 +58,7 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
         stream.Seek(0, SeekOrigin.Begin);
         return bytes;
     }
+    Queue<RoomFileDataBack> backQueue = new Queue<RoomFileDataBack>();
     // File uploader task.
     private async Task Run()
     {
@@ -77,11 +78,14 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
                                                                                     .WithObject(Nowfd.objectName)
                                                                                     .WithExpiry(60 * 60 * 24);
                                                   string url = await minio.PresignedGetObjectAsync(args);
-
                                                   RoomFileData rfd = new RoomFileData();
                                                   rfd.url = url;
                                                   rfd.bytes = StreamToBytes(stream);
-                                                  Nowfd.callBack(rfd);
+                                                  RoomFileDataBack rfdb = new RoomFileDataBack();
+                                                  rfdb.rfd = rfd;
+                                                  rfdb.Nowfd = Nowfd;
+                                                  backQueue.Enqueue(rfdb);
+
                                               });
             await minio.GetObjectAsync(getObjectArgs);
     }
@@ -144,11 +148,16 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
         fdQueue.Enqueue(getFileData);
     }
 
-   public class RoomFileData
+    public class RoomFileData
     {
         public byte[] bytes;
         public string url;
     }
+    public class RoomFileDataBack
+    {
+        public RoomFileData rfd;
+        public GetFileData Nowfd;
+    }
 
     GetFileData Nowfd;
     private void Update()
@@ -169,6 +178,13 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
 
             }
         }
+        if (backQueue.Count > 0 )
+        {
+            isUpdate = false;
+            RoomFileDataBack rfdb = backQueue.Dequeue();
+            rfdb.Nowfd.callBack?.Invoke(rfdb.rfd);
+        }
+        
     }
 
     public class GetFileData