Fixed loop.
Server class can't have an API class property, or a loop will prevent building.
This commit is contained in:
parent
0740c6daca
commit
69168acd22
@ -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
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -19,10 +19,9 @@ 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;
|
||||
|
Loading…
Reference in New Issue
Block a user