mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-19 14:50:10 +00:00
update download system
remove timeout
This commit is contained in:
@@ -16,14 +16,22 @@ namespace YooAsset
|
||||
private UnityWebRequestAsyncOperation _requestOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 响应的超时时间(单位:秒),在经过Timeout的秒数后尝试中止。
|
||||
/// 注意:当Timeout设置为0时,不会应用超时。
|
||||
/// 注意:设置的超时值可能应用于Android上的每个URL重定向,这可能会导致响应时间增加。
|
||||
/// </summary>
|
||||
private readonly int _timeout;
|
||||
|
||||
/// <summary>
|
||||
/// 请求结果
|
||||
/// </summary>
|
||||
public string Result { private set; get; }
|
||||
|
||||
|
||||
internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout)
|
||||
internal UnityWebTextRequestOperation(string url, int timeout) : base(url)
|
||||
{
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
@@ -36,7 +44,6 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
ResetTimeout();
|
||||
CreateWebRequest();
|
||||
_steps = ESteps.Download;
|
||||
}
|
||||
@@ -47,10 +54,7 @@ namespace YooAsset
|
||||
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
Progress = _requestOperation.progress;
|
||||
if (_requestOperation.isDone == false)
|
||||
{
|
||||
CheckRequestTimeout();
|
||||
return;
|
||||
}
|
||||
|
||||
if (CheckRequestResult())
|
||||
{
|
||||
@@ -81,8 +85,9 @@ namespace YooAsset
|
||||
|
||||
private void CreateWebRequest()
|
||||
{
|
||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||
DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
|
||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||
_webRequest.timeout = _timeout;
|
||||
_webRequest.downloadHandler = handler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
_requestOperation = _webRequest.SendWebRequest();
|
||||
|
||||
Reference in New Issue
Block a user