From 69168acd2250899486653f75186065df3b9adc5d Mon Sep 17 00:00:00 2001
From: JacobTech <jacob@jacobtech.com>
Date: Sun, 1 Oct 2023 13:12:27 -0400
Subject: [PATCH] Fixed loop.

Server class can't have an API class property, or a loop will prevent building.
---
 Luski.net/API.cs                  | 6 ++++--
 Luski.net/MainServer.cs           | 4 ++--
 Luski.net/PublicServer.Account.cs | 8 ++++----
 Luski.net/PublicServer.cs         | 8 ++++----
 Luski.net/Server.cs               | 7 +++----
 5 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/Luski.net/API.cs b/Luski.net/API.cs
index 4688b37..885b2cf 100644
--- a/Luski.net/API.cs
+++ b/Luski.net/API.cs
@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Text.Json.Serialization;
 using System.Threading.Tasks;
 using Luski.net.Enums;
 
@@ -9,6 +10,7 @@ namespace Luski.net;
 
 public class API
 {
+    [JsonIgnore]
     public MainServer MainServer { get; internal set; }
 
     public bool IsAnyServerLoggedin { get; internal set; }
@@ -40,7 +42,7 @@ public class API
         {
             IEnumerable<PublicServer> isl = InternalServers.Where(a => (a.Domain == Domain && a.ApiVersion == Version));
             if (isl.Any()) return isl.First();
-            s = await PublicServer.GetServer(this, Domain, Version, Secure);
+            s = await PublicServer.GetServer(Domain, Version, Secure);
         }
         catch (Exception e)
         {
@@ -84,7 +86,7 @@ public class API
     {
         DateTime dt = DateTime.UtcNow;
         Console.WriteLine("Conecting to main server '{0}' using API {1}.", Domain, Version);
-        MainServer = new(this, Domain, Version)
+        MainServer = new(Domain, Version)
         {
             ServerType = ServerType.Main
         };
diff --git a/Luski.net/MainServer.cs b/Luski.net/MainServer.cs
index 876c1f5..26f2f76 100644
--- a/Luski.net/MainServer.cs
+++ b/Luski.net/MainServer.cs
@@ -20,8 +20,8 @@ namespace Luski.net;
 
 public partial class MainServer : Server
 {
-    internal MainServer(API api, string Domain, string API_Version):
-        base(api, Domain, API_Version)
+    internal MainServer(string Domain, string API_Version):
+        base(Domain, API_Version)
     {
     }
 
diff --git a/Luski.net/PublicServer.Account.cs b/Luski.net/PublicServer.Account.cs
index 435e5a0..900aa6a 100644
--- a/Luski.net/PublicServer.Account.cs
+++ b/Luski.net/PublicServer.Account.cs
@@ -171,7 +171,7 @@ public partial class PublicServer
                 stor);
             EncryptionHandler.OfflinePublicKey = null!;
             EncryptionHandler.OfflinePrivateKey = null!;
-            API_Handler.IsAnyServerLoggedin = true;
+            //API_Handler.IsAnyServerLoggedin = true;
             return true;
         }
         else
@@ -179,7 +179,7 @@ public partial class PublicServer
             throw new Exception(json?.ErrorMessage);
         }
 
-        API_Handler.IsAnyServerLoggedin = true;
+        //API_Handler.IsAnyServerLoggedin = true;
         return true;
     }
 
@@ -346,12 +346,12 @@ public partial class PublicServer
            // _ = await setkey.PostAsync($"{(Secure ? "https" : "http" )}://{Domain}/{ApiVersion}/Keys/SetOfflineKey", new StringContent(EncryptionHandler.OfflinePublicKey));
             EncryptionHandler.OfflinePublicKey = null!;
             EncryptionHandler.OfflinePrivateKey = null!;
-            API_Handler.IsAnyServerLoggedin = true;
+            //API_Handler.IsAnyServerLoggedin = true;
             return true;
         }
         else throw new Exception(json?.ErrorMessage);
 
-        API_Handler.IsAnyServerLoggedin = true;
+        //API_Handler.IsAnyServerLoggedin = true;
         return true;
     }
 }
\ No newline at end of file
diff --git a/Luski.net/PublicServer.cs b/Luski.net/PublicServer.cs
index 8a7b9f3..1539d63 100644
--- a/Luski.net/PublicServer.cs
+++ b/Luski.net/PublicServer.cs
@@ -31,15 +31,15 @@ public partial class PublicServer : Server
 
     public SocketAppUser User { get; private set; } = null!;
 
-    private PublicServer(API api,string Domain, string API_Version, bool Secure = true) :
-        base(api, Domain, API_Version, Secure)
+    private PublicServer(string Domain, string API_Version, bool Secure = true) :
+        base(Domain, API_Version, Secure)
     { }
 
-    internal static async Task<PublicServer> GetServer(API api, string Domain, string API_Version, bool Secure = true)
+    internal static async Task<PublicServer> GetServer(string Domain, string API_Version, bool Secure = true)
     {
         DateTime dt = DateTime.UtcNow;
         Console.WriteLine("Connecting to public server '{0}' using API {1}.", Domain, API_Version);
-        PublicServer s = new(api, Domain, API_Version, Secure);
+        PublicServer s = new(Domain, API_Version, Secure);
         ServerInfo? si = null;
         try
         {
diff --git a/Luski.net/Server.cs b/Luski.net/Server.cs
index 4cd4916..d77dbf9 100644
--- a/Luski.net/Server.cs
+++ b/Luski.net/Server.cs
@@ -19,17 +19,16 @@ namespace Luski.net;
 
 public partial class Server
 {
-    internal API API_Handler;
-    internal Server(API api_handle, string Domain, string API_Version, bool Secure = true)
+    
+    internal Server(string Domain, string API_Version, bool Secure = true)
     {
-        API_Handler = api_handle;
         this.Domain = Domain;
         this.ApiVersion = API_Version;
         this.Secure = Secure;
         Storage = new(Domain);
         EncryptionHandler = new(Storage);
     }
-
+    
     internal bool Secure = true;
     internal string wssurl;