diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index ee89778..62116b9 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -118,10 +118,6 @@ namespace Bloxstrap App.Logger.WriteLine(LOG_IDENT, "Running bootstrapper"); - // connectivity check - - App.Logger.WriteLine(LOG_IDENT, "Performing connectivity check..."); - SetStatus(Strings.Bootstrapper_Status_Connecting); var connectionResult = await RobloxDeployment.InitializeConnectivity(); @@ -129,9 +125,7 @@ namespace Bloxstrap App.Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); if (connectionResult is not null) - { HandleConnectionError(connectionResult); - } #if !DEBUG || DEBUG_UPDATER if (App.Settings.Prop.CheckForUpdates && !App.LaunchSettings.UpgradeFlag.Active) diff --git a/Bloxstrap/GlobalCache.cs b/Bloxstrap/GlobalCache.cs index fcd6ede..6977224 100644 --- a/Bloxstrap/GlobalCache.cs +++ b/Bloxstrap/GlobalCache.cs @@ -2,8 +2,6 @@ { public static class GlobalCache { - public static readonly Dictionary PendingTasks = new(); - - public static readonly Dictionary ServerLocation = new(); + public static readonly Dictionary ServerLocation = new(); } } diff --git a/Bloxstrap/Models/ActivityData.cs b/Bloxstrap/Models/ActivityData.cs index 3a940e6..b99e81c 100644 --- a/Bloxstrap/Models/ActivityData.cs +++ b/Bloxstrap/Models/ActivityData.cs @@ -71,6 +71,8 @@ namespace Bloxstrap.Models public ICommand RejoinServerCommand => new RelayCommand(RejoinServer); + private SemaphoreSlim serverQuerySemaphore = new(1, 1); + public string GetInviteDeeplink(bool launchData = true) { string deeplink = $"roblox://experiences/start?placeId={PlaceId}"; @@ -86,29 +88,24 @@ namespace Bloxstrap.Models return deeplink; } - public async Task QueryServerLocation() + public async Task QueryServerLocation() { const string LOG_IDENT = "ActivityData::QueryServerLocation"; if (!MachineAddressValid) throw new InvalidOperationException($"Machine address is invalid ({MachineAddress})"); - if (GlobalCache.PendingTasks.TryGetValue(MachineAddress, out Task? task)) - await task; + await serverQuerySemaphore.WaitAsync(); if (GlobalCache.ServerLocation.TryGetValue(MachineAddress, out string? location)) + { + serverQuerySemaphore.Release(); return location; + } try { - location = ""; - var ipInfoTask = Http.GetJson($"https://ipinfo.io/{MachineAddress}/json"); - - GlobalCache.PendingTasks.Add(MachineAddress, ipInfoTask); - - var ipInfo = await ipInfoTask; - - GlobalCache.PendingTasks.Remove(MachineAddress); + var ipInfo = await Http.GetJson($"https://ipinfo.io/{MachineAddress}/json"); if (String.IsNullOrEmpty(ipInfo.City)) throw new InvalidHTTPResponseException("Reported city was blank"); @@ -119,18 +116,25 @@ namespace Bloxstrap.Models location = $"{ipInfo.City}, {ipInfo.Region}, {ipInfo.Country}"; GlobalCache.ServerLocation[MachineAddress] = location; - - return location; + serverQuerySemaphore.Release(); } catch (Exception ex) { App.Logger.WriteLine(LOG_IDENT, $"Failed to get server location for {MachineAddress}"); App.Logger.WriteException(LOG_IDENT, ex); - Frontend.ShowMessageBox($"{Strings.ActivityWatcher_LocationQueryFailed}\n\n{ex.Message}", MessageBoxImage.Warning); + GlobalCache.ServerLocation[MachineAddress] = location; + serverQuerySemaphore.Release(); - return "?"; + Frontend.ShowConnectivityDialog( + String.Format(Strings.Dialog_Connectivity_UnableToConnect, "ipinfo.io"), + Strings.ActivityWatcher_LocationQueryFailed, + MessageBoxImage.Warning, + ex + ); } + + return location; } public override string ToString() => $"{PlaceId}/{JobId}"; diff --git a/Bloxstrap/Models/SettingTasks/EmojiModPresetTask.cs b/Bloxstrap/Models/SettingTasks/EmojiModPresetTask.cs index 08c0edf..89c8d92 100644 --- a/Bloxstrap/Models/SettingTasks/EmojiModPresetTask.cs +++ b/Bloxstrap/Models/SettingTasks/EmojiModPresetTask.cs @@ -52,9 +52,12 @@ namespace Bloxstrap.Models.SettingTasks { App.Logger.WriteException(LOG_IDENT, ex); - Frontend.ShowMessageBox( - String.Format(Strings.Menu_Mods_Presets_EmojiType_Error, ex.Message), - MessageBoxImage.Warning); + Frontend.ShowConnectivityDialog( + String.Format(Strings.Dialog_Connectivity_UnableToConnect, "GitHub"), + $"{Strings.Menu_Mods_Presets_EmojiType_Error}\n\n{Strings.Dialog_Connectivity_TryAgainLater}", + MessageBoxImage.Warning, + ex + ); } } else if (query is not null && query.Any()) diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 99eb9bd..1462950 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -106,7 +106,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Failed to query server location.. + /// Looks up a localized string similar to The server location could not be queried. You may be joining games too quickly.. /// public static string ActivityWatcher_LocationQueryFailed { get { @@ -512,6 +512,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Not available. + /// + public static string Common_NotAvailable { + get { + return ResourceManager.GetString("Common.NotAvailable", resourceCulture); + } + } + /// /// Looks up a localized string similar to OK. /// @@ -2891,9 +2900,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to The emoji mod could not be applied because of a network error during download. - /// - ///{0}. + /// Looks up a localized string similar to The emoji mod can not be applied at this time.. /// public static string Menu_Mods_Presets_EmojiType_Error { get { diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 0e2ebd1..8cedffc 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1096,9 +1096,7 @@ If not, then please report this exception to the maintainers of this fork. Do NO Connected to reserved server - The emoji mod could not be applied because of a network error during download. - -{0} + The emoji mod can not be applied at this time. Please wait for installation to finish. @@ -1163,7 +1161,7 @@ Are you sure you want to continue? Game history is only recorded for your current Roblox session. Games will appear here as you leave them or teleport within them. - Failed to query server location. + The server location could not be queried. You may be joining games too quickly. {0} may be down right now. @@ -1182,4 +1180,7 @@ Are you sure you want to continue? Please manually delete Bloxstrap.exe from the install location or try restarting your system, and then retry installation afterwards. + + Not available + \ No newline at end of file diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index d15b2d0..85dfac7 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -59,7 +59,7 @@ namespace Bloxstrap.UI if (_activityWatcher is null) return; - string serverLocation = await _activityWatcher.Data.QueryServerLocation(); + string? serverLocation = await _activityWatcher.Data.QueryServerLocation(); if (string.IsNullOrEmpty(serverLocation)) return; diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs index 420b916..8e1eccd 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs @@ -29,7 +29,13 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu public async void QueryServerLocation() { - ServerLocation = await _activityWatcher.Data.QueryServerLocation(); + string? location = await _activityWatcher.Data.QueryServerLocation(); + + if (String.IsNullOrEmpty(location)) + ServerLocation = Strings.Common_NotAvailable; + else + ServerLocation = location; + OnPropertyChanged(nameof(ServerLocation)); }