36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
|
|
using YooAsset;
|
|||
|
|
namespace Stary.Evo
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class RemoteServices : IRemoteServices
|
|||
|
|
{
|
|||
|
|
private readonly string _mainHost;
|
|||
|
|
private readonly string _fallbackHost;
|
|||
|
|
|
|||
|
|
public RemoteServices(string mainHost, string fallbackHost = null)
|
|||
|
|
{
|
|||
|
|
_mainHost = mainHost.TrimEnd('/');
|
|||
|
|
_fallbackHost = string.IsNullOrEmpty(fallbackHost)
|
|||
|
|
? _mainHost
|
|||
|
|
: fallbackHost.TrimEnd('/');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 主下载地址(YooAsset 会优先使用)
|
|||
|
|
/// fileName 示例:DefaultPackage/StaticAssets/DefaultPackage.version
|
|||
|
|
/// </summary>
|
|||
|
|
public string GetRemoteMainURL(string fileName)
|
|||
|
|
{
|
|||
|
|
return $"{_mainHost}/{fileName}";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 备用下载地址(主地址失败时自动重试)
|
|||
|
|
/// </summary>
|
|||
|
|
public string GetRemoteFallbackURL(string fileName)
|
|||
|
|
{
|
|||
|
|
return $"{_fallbackHost}/{fileName}";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|