Skip to content

Commit

Permalink
support new ea's url, support for .zone domain (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKhalow authored Aug 19, 2024
1 parent a1063ed commit 21139f4
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace DCL.Multiplayer.Connections.DecentralandUrls
public enum DecentralandUrl
{
Host,
Genesis,

ArchipelagoStatus,
GatekeeperStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ private static string RawUrl(DecentralandUrl decentralandUrl) =>
DecentralandUrl.Notification => $"https://notifications.decentraland.{ENV}/notifications",
DecentralandUrl.NotificationRead => $"https://notifications.decentraland.{ENV}/notifications/read",
DecentralandUrl.FeatureFlags => $"https://feature-flags.decentraland.{ENV}",
DecentralandUrl.Market => $"https://market.decentraland.org",
DecentralandUrl.AssetBundlesCDN => $"https://ab-cdn.decentraland.org",
DecentralandUrl.Market => "https://market.decentraland.org",
DecentralandUrl.AssetBundlesCDN => "https://ab-cdn.decentraland.org",
DecentralandUrl.ArchipelagoStatus => $"https://archipelago-stats.decentraland.{ENV}/status",
DecentralandUrl.GatekeeperStatus => $"https://comms-gatekeeper.decentraland.{ENV}/status",
_ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null)
DecentralandUrl.Genesis => $"https://realm-provider-ea.decentraland.{ENV}/main",
_ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!)
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace ECS.SceneLifeCycle.Realm
{
public interface IRealmNavigator
{
public const string GENESIS_URL = "https://realm-provider.decentraland.org/main";
public const string WORLDS_DOMAIN = "https://worlds-content-server.decentraland.org/world";
public const string LOCALHOST = "http://127.0.0.1:8000";

Expand Down
4 changes: 2 additions & 2 deletions Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CancellationToken ct
WebBrowser = browser,
DebugSettings = debugSettings,
CommandLineArgs = new CommandLineArgs(),
LocalSceneDevelopment = appParametersParser.LocalSceneDevelopment || launchSettings.GetStartingRealm() == IRealmNavigator.LOCALHOST,
LocalSceneDevelopment = appParametersParser.LocalSceneDevelopment || launchSettings.StartingRealmUrl(decentralandUrlsSource) == IRealmNavigator.LOCALHOST,
};

await bootstrapContainer.InitializeContainerAsync<BootstrapContainer, BootstrapSettings>(settingsContainer, ct, async container =>
Expand All @@ -91,7 +91,7 @@ await bootstrapContainer.InitializeContainerAsync<BootstrapContainer, BootstrapS
AnalyticsConfiguration analyticsConfig = (await container.AssetsProvisioner.ProvideMainAssetAsync(bootstrapSettings.AnalyticsConfigRef, ct)).Value;
container.enableAnalytics = analyticsConfig.Mode != AnalyticsMode.DISABLED;

var coreBootstrap = new Bootstrap(debugSettings, commandLineArgs)
var coreBootstrap = new Bootstrap(debugSettings, commandLineArgs, container.DecentralandUrlsSource)
{
EnableAnalytics = container.enableAnalytics,
};
Expand Down
17 changes: 11 additions & 6 deletions Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ namespace Global.Dynamic
public class Bootstrap : IBootstrap
{
private readonly IDebugSettings debugSettings;
private readonly IDecentralandUrlsSource decentralandUrlsSource;
private readonly ICommandLineArgs commandLineArgs;

private URLDomain startingRealm = URLDomain.FromString(IRealmNavigator.GENESIS_URL);
private URLDomain? startingRealm;
private Vector2Int startingParcel;
private DynamicWorldDependencies dynamicWorldDependencies;
private Dictionary<string, string> appParameters = new ();
private readonly Dictionary<string, string> appParameters = new ();

public bool EnableAnalytics { private get; init; }

public Bootstrap(IDebugSettings debugSettings, ICommandLineArgs commandLineArgs)
public Bootstrap(IDebugSettings debugSettings, ICommandLineArgs commandLineArgs, IDecentralandUrlsSource decentralandUrlsSource)
{
this.debugSettings = debugSettings;
this.decentralandUrlsSource = decentralandUrlsSource;
this.commandLineArgs = commandLineArgs;
}

Expand All @@ -53,7 +55,7 @@ public void PreInitializeSetup(RealmLaunchSettings launchSettings, UIDocument cu
splashScreen.ShowSplash();
cursorRoot.EnsureNotNull();

startingRealm = URLDomain.FromString(launchSettings.GetStartingRealm());
startingRealm = URLDomain.FromString(launchSettings.StartingRealmUrl(decentralandUrlsSource));
startingParcel = launchSettings.TargetScene;

// Hides the debug UI during the initial flow
Expand Down Expand Up @@ -110,7 +112,7 @@ CancellationToken ct
EnableLandscape = debugSettings.EnableLandscape && !bootstrapContainer.LocalSceneDevelopment,
EnableLOD = debugSettings.EnableLOD && !bootstrapContainer.LocalSceneDevelopment,
EnableAnalytics = EnableAnalytics, HybridSceneParams = launchSettings.CreateHybridSceneParams(startingParcel),
LocalSceneDevelopmentRealm = bootstrapContainer.LocalSceneDevelopment ? launchSettings.GetStartingRealm() : string.Empty,
LocalSceneDevelopmentRealm = bootstrapContainer.LocalSceneDevelopment ? launchSettings.StartingRealmUrl(decentralandUrlsSource) : string.Empty,
AppParameters = appParameters,
},
backgroundMusic,
Expand Down Expand Up @@ -175,7 +177,10 @@ UIDocument debugUiRoot

public async UniTask LoadStartingRealmAsync(DynamicWorldContainer dynamicWorldContainer, CancellationToken ct)
{
await dynamicWorldContainer.RealmController.SetRealmAsync(startingRealm, ct);
if (startingRealm.HasValue == false)
throw new InvalidOperationException("Starting realm is not set");

await dynamicWorldContainer.RealmController.SetRealmAsync(startingRealm.Value, ct);
}

public async UniTask UserInitializationAsync(DynamicWorldContainer dynamicWorldContainer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommunicationData.URLHelpers;
using Cysharp.Threading.Tasks;
using DCL.Chat.Commands;
using DCL.Multiplayer.Connections.DecentralandUrls;
using ECS.SceneLifeCycle.Realm;
using System.Collections.Generic;
using System.Text.RegularExpressions;
Expand All @@ -24,15 +25,7 @@ public class ChangeRealmChatCommand : IChatCommand
private const string WORLD_SUFFIX = ".dcl.eth";

// Parameters to URL mapping
private static readonly Dictionary<string, string> PARAM_URLS = new ()
{
{ "genesis", IRealmNavigator.GENESIS_URL },
{ "goerli", IRealmNavigator.GOERLI_URL },
{ "goerli-old", IRealmNavigator.GOERLI_OLD_URL },
{ "stream", IRealmNavigator.STREAM_WORLD_URL },
{ "sdk", IRealmNavigator.SDK_TEST_SCENES_URL },
{ "test", IRealmNavigator.TEST_SCENES_URL },
};
private readonly Dictionary<string, string> paramUrls;

public static readonly Regex REGEX = new ($@"^/({COMMAND_WORLD}|{COMMAND_GOTO})\s+((?!-?\d+\s*,\s*-?\d+$).+?)(?:\s+(-?\d+)\s*,\s*(-?\d+))?$", RegexOptions.Compiled);
private readonly URLDomain worldDomain = URLDomain.FromString(IRealmNavigator.WORLDS_DOMAIN);
Expand All @@ -43,16 +36,26 @@ public class ChangeRealmChatCommand : IChatCommand
private string? worldName;
private string? realmUrl;

public ChangeRealmChatCommand(IRealmNavigator realmNavigator)
public ChangeRealmChatCommand(IRealmNavigator realmNavigator, IDecentralandUrlsSource decentralandUrlsSource)
{
this.realmNavigator = realmNavigator;

paramUrls = new Dictionary<string, string>
{
{ "genesis", decentralandUrlsSource.Url(DecentralandUrl.Genesis) },
{ "goerli", IRealmNavigator.GOERLI_URL },
{ "goerli-old", IRealmNavigator.GOERLI_OLD_URL },
{ "stream", IRealmNavigator.STREAM_WORLD_URL },
{ "sdk", IRealmNavigator.SDK_TEST_SCENES_URL },
{ "test", IRealmNavigator.TEST_SCENES_URL },
};
}

public async UniTask<string> ExecuteAsync(Match match, CancellationToken ct)
{
worldName = match.Groups[2].Value;

if (!PARAM_URLS.TryGetValue(worldName, out realmUrl))
if (!paramUrls.TryGetValue(worldName, out realmUrl))
{
if (!worldName.EndsWith(WORLD_SUFFIX))
worldName += WORLD_SUFFIX;
Expand All @@ -63,6 +66,7 @@ public async UniTask<string> ExecuteAsync(Match match, CancellationToken ct)
var realm = URLDomain.FromString(realmUrl!);

Vector2Int parcel = default;

if (match.Groups[3].Success && match.Groups[4].Success)
parcel = new Vector2Int(int.Parse(match.Groups[3].Value), int.Parse(match.Groups[4].Value));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain
parcelServiceContainer.TeleportController,
container.RoomHub,
remoteEntities,
bootstrapContainer.DecentralandUrlsSource,
staticContainer.GlobalWorldProxy,
container.LODContainer.RoadPlugin,
genesisTerrain,
Expand Down Expand Up @@ -369,7 +370,7 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain
var chatCommandsFactory = new Dictionary<Regex, Func<IChatCommand>>
{
{ GoToChatCommand.REGEX, () => new GoToChatCommand(realmNavigator) },
{ ChangeRealmChatCommand.REGEX, () => new ChangeRealmChatCommand(realmNavigator) },
{ ChangeRealmChatCommand.REGEX, () => new ChangeRealmChatCommand(realmNavigator, bootstrapContainer.DecentralandUrlsSource) },
{ DebugPanelChatCommand.REGEX, () => new DebugPanelChatCommand(debugBuilder) },
{ ShowEntityInfoChatCommand.REGEX, () => new ShowEntityInfoChatCommand(worldInfoHub) },
{ ClearChatCommand.REGEX, () => new ClearChatCommand(chatHistory) },
Expand Down
9 changes: 5 additions & 4 deletions Explorer/Assets/Scripts/Global/Dynamic/RealmLaunchSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ECS.SceneLifeCycle.Realm;
using DCL.Multiplayer.Connections.DecentralandUrls;
using ECS.SceneLifeCycle.Realm;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -46,19 +47,19 @@ public HybridSceneParams CreateHybridSceneParams(Vector2Int startParcel)
return new HybridSceneParams();
}

public string GetStartingRealm()
public string StartingRealmUrl(IDecentralandUrlsSource decentralandUrlsSource)
{
return initialRealm switch
{
InitialRealm.GenesisCity => IRealmNavigator.GENESIS_URL,
InitialRealm.GenesisCity => decentralandUrlsSource.Url(DecentralandUrl.Genesis),
InitialRealm.SDK => IRealmNavigator.SDK_TEST_SCENES_URL,
InitialRealm.Goerli => IRealmNavigator.GOERLI_URL,
InitialRealm.StreamingWorld => IRealmNavigator.STREAM_WORLD_URL,
InitialRealm.TestScenes => IRealmNavigator.TEST_SCENES_URL,
InitialRealm.World => IRealmNavigator.WORLDS_DOMAIN + "/" + targetWorld,
InitialRealm.Localhost => IRealmNavigator.LOCALHOST,
InitialRealm.Custom => customRealm,
_ => IRealmNavigator.GENESIS_URL,
_ => decentralandUrlsSource.Url(DecentralandUrl.Genesis),
};
}

Expand Down
14 changes: 9 additions & 5 deletions Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using DCL.Landscape;
using DCL.MapRenderer;
using DCL.MapRenderer.MapLayers;
using DCL.Multiplayer.Connections.DecentralandUrls;
using DCL.Multiplayer.Connections.RoomHubs;
using DCL.Multiplayer.Profiles.Entities;
using DCL.ParcelsService;
Expand Down Expand Up @@ -33,14 +34,13 @@ namespace Global.Dynamic
{
public class RealmNavigator : IRealmNavigator
{
private readonly URLDomain genesisDomain = URLDomain.FromString(IRealmNavigator.GENESIS_URL);

private readonly ILoadingScreen loadingScreen;
private readonly IMapRenderer mapRenderer;
private readonly IGlobalRealmController realmController;
private readonly ITeleportController teleportController;
private readonly IRoomHub roomHub;
private readonly IRemoteEntities remoteEntities;
private readonly IDecentralandUrlsSource decentralandUrlsSource;
private readonly ObjectProxy<World> globalWorldProxy;
private readonly RoadPlugin roadsPlugin;
private readonly TerrainGenerator genesisTerrain;
Expand All @@ -62,6 +62,7 @@ public RealmNavigator(
ITeleportController teleportController,
IRoomHub roomHub,
IRemoteEntities remoteEntities,
IDecentralandUrlsSource decentralandUrlsSource,
ObjectProxy<World> globalWorldProxy,
RoadPlugin roadsPlugin,
TerrainGenerator genesisTerrain,
Expand All @@ -84,6 +85,7 @@ public RealmNavigator(
this.cameraSamplingData = cameraSamplingData;
this.roomHub = roomHub;
this.remoteEntities = remoteEntities;
this.decentralandUrlsSource = decentralandUrlsSource;
this.globalWorldProxy = globalWorldProxy;
}

Expand Down Expand Up @@ -168,9 +170,12 @@ public async UniTask TryInitializeTeleportToParcelAsync(Vector2Int parcel, Cance
{
bool isGenesis = !realmController.RealmData.ScenesAreFixed;

if (!isLocal && !isGenesis) { await TryChangeRealmAsync(genesisDomain, ct, parcel); }
else
if (!isLocal && !isGenesis)
{
var url = URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.Genesis));
await TryChangeRealmAsync(url, ct, parcel);
}
else
await loadingScreen.ShowWhileExecuteTaskAsync(async parentLoadReport =>
{
ct.ThrowIfCancellationRequested();
Expand All @@ -184,7 +189,6 @@ await loadingScreen.ShowWhileExecuteTaskAsync(async parentLoadReport =>
parentLoadReport.SetProgress(RealFlowLoadingStatus.PROGRESS[Completed]);
}, ct);
}
}
catch (TimeoutException) { }
}
Expand Down

0 comments on commit 21139f4

Please sign in to comment.