mirror of https://github.com/tuyoogame/YooAsset
update package system
1. 移除了HostPlayModeParameters.DefaultHostServer字段 2. 移除了HostPlayModeParameters.FallbackHostServer字段 3. 新增了HostPlayModeParameters.RemoteServices字段pull/134/head
parent
829ea66d0e
commit
472a5ae97a
|
@ -73,9 +73,7 @@ namespace YooAsset
|
|||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
string filePath = Provider.RawFilePath;
|
||||
if (File.Exists(filePath) == false)
|
||||
return null;
|
||||
return File.ReadAllBytes(filePath);
|
||||
return FileUtility.ReadAllBytes(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -80,19 +80,14 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public class HostPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认的资源服务器下载地址
|
||||
/// </summary>
|
||||
public string DefaultHostServer = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 备用的资源服务器下载地址
|
||||
/// </summary>
|
||||
public string FallbackHostServer = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源查询服务接口
|
||||
/// </summary>
|
||||
public IQueryServices QueryServices = null;
|
||||
|
||||
/// <summary>
|
||||
/// 远端资源地址查询服务类
|
||||
/// </summary>
|
||||
public IRemoteServices RemoteServices = null;
|
||||
}
|
||||
}
|
|
@ -169,7 +169,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_downloadManifestOp == null)
|
||||
{
|
||||
_downloadManifestOp = new DownloadManifestOperation(_impl, _packageName, _packageVersion, _timeout);
|
||||
_downloadManifestOp = new DownloadManifestOperation(_impl.RemoteServices, _packageName, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_downloadManifestOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_downloadManifestOp == null)
|
||||
{
|
||||
_downloadManifestOp = new DownloadManifestOperation(_impl, _packageName, _packageVersion, _timeout);
|
||||
_downloadManifestOp = new DownloadManifestOperation(_impl.RemoteServices, _packageName, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_downloadManifestOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_queryRemotePackageVersionOp == null)
|
||||
{
|
||||
_queryRemotePackageVersionOp = new QueryRemotePackageVersionOperation(_impl, _packageName, _appendTimeTicks, _timeout);
|
||||
_queryRemotePackageVersionOp = new QueryRemotePackageVersionOperation(_impl.RemoteServices, _packageName, _appendTimeTicks, _timeout);
|
||||
OperationSystem.StartOperation(_queryRemotePackageVersionOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,25 +4,28 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices, IRemoteServices
|
||||
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PackageManifest _activeManifest;
|
||||
|
||||
// 参数相关
|
||||
private string _packageName;
|
||||
private string _defaultHostServer;
|
||||
private string _fallbackHostServer;
|
||||
private IQueryServices _queryServices;
|
||||
private IRemoteServices _remoteServices;
|
||||
|
||||
public IRemoteServices RemoteServices
|
||||
{
|
||||
get { return _remoteServices; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(string packageName, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices)
|
||||
public InitializationOperation InitializeAsync(string packageName, IQueryServices queryServices, IRemoteServices remoteServices)
|
||||
{
|
||||
_packageName = packageName;
|
||||
_defaultHostServer = defaultHostServer;
|
||||
_fallbackHostServer = fallbackHostServer;
|
||||
_queryServices = queryServices;
|
||||
_remoteServices = remoteServices;
|
||||
|
||||
var operation = new HostPlayModeInitializationOperation(this, packageName);
|
||||
OperationSystem.StartOperation(operation);
|
||||
|
@ -42,23 +45,12 @@ namespace YooAsset
|
|||
}
|
||||
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
||||
{
|
||||
string remoteMainURL = GetRemoteMainURL(packageBundle.FileName);
|
||||
string remoteFallbackURL = GetRemoteFallbackURL(packageBundle.FileName);
|
||||
string remoteMainURL = _remoteServices.GetRemoteMainURL(packageBundle.FileName);
|
||||
string remoteFallbackURL = _remoteServices.GetRemoteFallbackURL(packageBundle.FileName);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
#region IRemoteServices接口
|
||||
public string GetRemoteMainURL(string fileName)
|
||||
{
|
||||
return $"{_defaultHostServer}/{fileName}";
|
||||
}
|
||||
public string GetRemoteFallbackURL(string fileName)
|
||||
{
|
||||
return $"{_fallbackHostServer}/{fileName}";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PackageManifest ActiveManifest
|
||||
{
|
||||
|
|
|
@ -122,9 +122,8 @@ namespace YooAsset
|
|||
var initializeParameters = parameters as HostPlayModeParameters;
|
||||
initializeOperation = hostPlayModeImpl.InitializeAsync(
|
||||
PackageName,
|
||||
initializeParameters.DefaultHostServer,
|
||||
initializeParameters.FallbackHostServer,
|
||||
initializeParameters.QueryServices
|
||||
initializeParameters.QueryServices,
|
||||
initializeParameters.RemoteServices
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -172,12 +171,10 @@ namespace YooAsset
|
|||
if (parameters is HostPlayModeParameters)
|
||||
{
|
||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||
if (string.IsNullOrEmpty(hostPlayModeParameters.DefaultHostServer))
|
||||
throw new Exception($"${hostPlayModeParameters.DefaultHostServer} is null or empty.");
|
||||
if (string.IsNullOrEmpty(hostPlayModeParameters.FallbackHostServer))
|
||||
throw new Exception($"${hostPlayModeParameters.FallbackHostServer} is null or empty.");
|
||||
if (hostPlayModeParameters.QueryServices == null)
|
||||
throw new Exception($"{nameof(IQueryServices)} is null.");
|
||||
if (hostPlayModeParameters.RemoteServices == null)
|
||||
throw new Exception($"{nameof(IRemoteServices)} is null.");
|
||||
}
|
||||
|
||||
// 鉴定运行模式
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface IRemoteServices
|
||||
public interface IRemoteServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取主资源站的资源地址
|
||||
/// </summary>
|
||||
/// <param name="fileName">请求的文件名称</param>
|
||||
string GetRemoteMainURL(string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取备用资源站的资源地址
|
||||
/// </summary>
|
||||
/// <param name="fileName">请求的文件名称</param>
|
||||
string GetRemoteFallbackURL(string fileName);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue