using System; using System.Collections.Generic; using System.Text.Json; using BestHTTP; using Il2CppInterop.Runtime; using RecNet; using RecRoom.Async; namespace undead_universal_patch_il2cpp.Core.CustomRecNet; public class RecNetInteractions { public static string AccessToken { get; set; } public static List postNameServerActions = []; public static List postAuthenticationActions = []; public static Il2CppSystem.Uri CreateServiceUri(Service service, string pathAndQuery) { Il2CppSystem.Uri uri = RecNet.Core.GetServiceUri(service) ?? throw new Exception("Service is not available"); var newUri = new Il2CppSystem.Uri(uri, pathAndQuery); return newUri; } public static bool HasNameserverConnected() { return RecNet.Core.ServiceUris.Count > 1; } public static void SendRequest(HTTPMethods method, Service service, string requestUri, Action reqFinished) { var res = RecNet.Core.SendRequest(method, service, requestUri); res.Then(DelegateSupport.ConvertDelegate>((HTTPResponse res) => { try { var data = JsonSerializer.Deserialize(res.DataAsText); reqFinished(data); } catch (Exception ex) { UniversalPatchPlugin.Log.LogError($"'{requestUri}' failed\n{ex}"); } })); } }