- add: fallbacks
This commit is contained in:
@@ -6,10 +6,16 @@ namespace Nebula.Shared;
|
||||
public static class CurrentConVar
|
||||
{
|
||||
public static readonly ConVar<string[]> EngineManifestUrl =
|
||||
ConVarBuilder.Build<string[]>("engine.manifestUrl", ["https://robust-builds.cdn.spacestation14.com/manifest.json"]);
|
||||
ConVarBuilder.Build<string[]>("engine.manifestUrl", [
|
||||
"https://robust-builds.cdn.spacestation14.com/manifest.json",
|
||||
"https://robust-builds.fallback.cdn.spacestation14.com/manifest.json"
|
||||
]);
|
||||
|
||||
public static readonly ConVar<string[]> EngineModuleManifestUrl =
|
||||
ConVarBuilder.Build<string[]>("engine.moduleManifestUrl", ["https://robust-builds.cdn.spacestation14.com/modules.json"]);
|
||||
ConVarBuilder.Build<string[]>("engine.moduleManifestUrl", [
|
||||
"https://robust-builds.cdn.spacestation14.com/modules.json",
|
||||
"https://robust-builds.fallback.cdn.spacestation14.com/modules.json"
|
||||
]);
|
||||
|
||||
public static readonly ConVar<int> ManifestDownloadProtocolVersion =
|
||||
ConVarBuilder.Build("engine.manifestDownloadProtocolVersion", 1);
|
||||
@@ -17,8 +23,8 @@ public static class CurrentConVar
|
||||
public static readonly ConVar<string> RobustAssemblyName =
|
||||
ConVarBuilder.Build("engine.robustAssemblyName", "Robust.Client");
|
||||
|
||||
public static readonly ConVar<string[]> Hub = ConVarBuilder.Build<string[]>("launcher.hub", [
|
||||
"https://hub.spacestation14.com/api/servers"
|
||||
public static readonly ConVar<string[][]> Hub = ConVarBuilder.Build<string[][]>("launcher.hub", [
|
||||
["https://hub.spacestation14.com/api/servers", "https://auth.fallback.spacestation14.com/"]
|
||||
]);
|
||||
|
||||
public static readonly ConVar<Dictionary<string, EngineVersionInfo>> EngineManifestBackup =
|
||||
|
||||
@@ -7,6 +7,7 @@ public class HubService
|
||||
{
|
||||
private readonly ConfigurationService _configurationService;
|
||||
private readonly RestService _restService;
|
||||
private readonly DebugService _debugService;
|
||||
|
||||
private readonly List<ServerHubInfo> _serverList = new();
|
||||
|
||||
@@ -14,10 +15,11 @@ public class HubService
|
||||
public Action? HubServerLoaded;
|
||||
public Action<Exception>? HubServerLoadingError;
|
||||
|
||||
public HubService(ConfigurationService configurationService, RestService restService)
|
||||
public HubService(ConfigurationService configurationService, RestService restService, DebugService debugService)
|
||||
{
|
||||
_configurationService = configurationService;
|
||||
_restService = restService;
|
||||
_debugService = debugService;
|
||||
|
||||
UpdateHub();
|
||||
}
|
||||
@@ -37,17 +39,29 @@ public class HubService
|
||||
|
||||
foreach (var urlStr in _configurationService.GetConfigValue(CurrentConVar.Hub)!)
|
||||
{
|
||||
try
|
||||
var invoked = false;
|
||||
Exception? exception = null;
|
||||
foreach (var uri in urlStr)
|
||||
{
|
||||
var servers =
|
||||
await _restService.GetAsync<List<ServerHubInfo>>(new Uri(urlStr), CancellationToken.None);
|
||||
_serverList.AddRange(servers);
|
||||
HubServerChangedEventArgs?.Invoke(new HubServerChangedEventArgs(servers, HubServerChangeAction.Add));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
HubServerLoadingError?.Invoke(e);
|
||||
try
|
||||
{
|
||||
var servers =
|
||||
await _restService.GetAsync<List<ServerHubInfo>>(new Uri(uri), CancellationToken.None);
|
||||
_serverList.AddRange(servers);
|
||||
HubServerChangedEventArgs?.Invoke(new HubServerChangedEventArgs(servers, HubServerChangeAction.Add));
|
||||
invoked = true;
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_debugService.Error($"Failed to get servers for {uri}");
|
||||
_debugService.Error(e);
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
|
||||
if(exception is not null && !invoked)
|
||||
HubServerLoadingError?.Invoke(new Exception("No hub is available.", exception));
|
||||
}
|
||||
|
||||
IsUpdating = false;
|
||||
|
||||
Reference in New Issue
Block a user