mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] Update版本更新时CDN地址也可更新
[+] Update版本更新时CDN地址也可更新
This commit is contained in:
41
Assets/TEngine/Runtime/GameFramework/Utility/Utility.Http.cs
Normal file
41
Assets/TEngine/Runtime/GameFramework/Utility/Utility.Http.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public static partial class Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Http 相关的实用函数。
|
||||
/// </summary>
|
||||
public static partial class Http
|
||||
{
|
||||
/// <summary>
|
||||
/// GET请求与获取结果。
|
||||
/// </summary>
|
||||
public static async UniTask<string> Get(string url,float timeout = 5f)
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.CancelAfterSlim(TimeSpan.FromSeconds(timeout));
|
||||
|
||||
UnityWebRequest unityWebRequest = UnityWebRequest.Get(url);
|
||||
try
|
||||
{
|
||||
await unityWebRequest.SendWebRequest().WithCancellation(cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
if (ex.CancellationToken == cts.Token)
|
||||
{
|
||||
Debug.Log("HttpGet Timeout");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
return unityWebRequest.downloadHandler.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da0e9fec46234724b7f73d9c49a92603
|
||||
timeCreated: 1688475202
|
@@ -52,6 +52,11 @@ public enum GameStatus
|
||||
/// </summary>
|
||||
public class UpdateData
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前版本信息。
|
||||
/// </summary>
|
||||
public string CurrentVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 是否底包更新。
|
||||
/// </summary>
|
||||
@@ -66,6 +71,16 @@ public class UpdateData
|
||||
/// 是否提示。
|
||||
/// </summary>
|
||||
public UpdateNotice UpdateNotice;
|
||||
|
||||
/// <summary>
|
||||
/// 热更资源地址。
|
||||
/// </summary>
|
||||
public string HostServerURL;
|
||||
|
||||
/// <summary>
|
||||
/// 备用热更资源地址。
|
||||
/// </summary>
|
||||
public string FallbackHostServerURL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user