From c512e7f385a748d8d9cbe55785a2b4e7cfbeefc3 Mon Sep 17 00:00:00 2001 From: Bitl Date: Thu, 4 Aug 2022 16:27:20 -0700 Subject: [PATCH] fixed hanging --- .../StorageAndFunctions/GlobalFuncs.cs | 49 ++++++++++++++----- .../StorageAndFunctions/GlobalVars.cs | 1 + 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index 29bee3b..f560ab4 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -2293,10 +2293,8 @@ public class GlobalFuncs case ScriptType.Server: #if LAUNCHER PingMasterServer(true, "Server will now display on the defined master server.", box); - ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4, box); #elif CMD PingMasterServer(true, "Server will now display on the defined master server."); - ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4); #endif goto default; default: @@ -2341,12 +2339,10 @@ public class GlobalFuncs public static void PingMasterServer(bool online, string reason) #endif { - string pingURL = ""; - if (online) { GlobalVars.ServerID = SecurityFuncs.RandomString(30) + SecurityFuncs.GenerateRandomNumber(); - pingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + + GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "/list.php?name=" + GlobalVars.UserConfiguration.ServerBrowserServerName + "&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) + "&port=" + GlobalVars.UserConfiguration.RobloxPort + @@ -2356,7 +2352,7 @@ public class GlobalFuncs } else { - pingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + + GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress + "/delist.php?id=" + GlobalVars.ServerID; GlobalVars.ServerID = "N/A"; } @@ -2366,17 +2362,46 @@ public class GlobalFuncs #elif CMD ConsolePrint("Pinging master server. " + reason, 4); #endif - string response = HttpGet(pingURL); + #if LAUNCHER - ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4, box); + Task.Factory.StartNew(() => TryPing(box)); +#else + Task.Factory.StartNew(() => TryPing()); +#endif + } + +#if LAUNCHER + public static void TryPing(RichTextBox box) +#else + private static void TryPing() +#endif + { + string response = HttpGet(GlobalVars.PingURL); + + if (!string.IsNullOrWhiteSpace(response)) + { +#if LAUNCHER + ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4, box); #elif CMD - ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4); + ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4); #endif - if (response.Contains("ERROR:")) - { - GlobalVars.ServerID = "N/A"; + if (response.Contains("ERROR:")) + { + GlobalVars.ServerID = "N/A"; + } } + + if (GlobalVars.ServerID == "N/A") + { +#if LAUNCHER + ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4, box); +#elif CMD + ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4); +#endif + } + + GlobalVars.PingURL = ""; } public static void OpenClient(ScriptType type, string rbxexe, string args, string clientname, string mapname, EventHandler e, bool customization = false) diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs index 464df51..b0aa279 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalVars.cs @@ -97,6 +97,7 @@ public static class GlobalVars public static int ValidatedExtraFiles = 0; public static bool NoFileList = false; public static string ServerID = "N/A"; + public static string PingURL = ""; #endregion } #endregion