refactor : 重构网络下载模块
新增通用下载接口,扩展了默认的Unity引擎下载器
This commit is contained in:
+9
-8
@@ -10,10 +10,11 @@ internal class RequestWebPackageVersionOperation : AsyncOperationBase
|
||||
}
|
||||
|
||||
private readonly IRemoteServices _remoteServices;
|
||||
private readonly IDownloadBackend _downloadBackend;
|
||||
private readonly string _packageName;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private IDownloadTextRequest _webTextRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -23,9 +24,10 @@ internal class RequestWebPackageVersionOperation : AsyncOperationBase
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
public RequestWebPackageVersionOperation(IRemoteServices remoteServices, string packageName, bool appendTimeTicks, int timeout)
|
||||
public RequestWebPackageVersionOperation(IRemoteServices remoteServices, IDownloadBackend downloadBackend, string packageName, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_remoteServices = remoteServices;
|
||||
_downloadBackend = downloadBackend;
|
||||
_packageName = packageName;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
@@ -46,17 +48,16 @@ internal class RequestWebPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
||||
string url = GetRequestURL(fileName);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
var args = new DownloadDataRequestArgs(url, _timeout, 0);
|
||||
_webTextRequestOp = _downloadBackend.CreateTextRequest(args);
|
||||
_webTextRequestOp.SendRequest();
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
Progress = _webTextRequestOp.Progress;
|
||||
Progress = _webTextRequestOp.DownloadProgress;
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||
if (_webTextRequestOp.Status == EDownloadRequestStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _webTextRequestOp.Result;
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
|
||||
Reference in New Issue
Block a user