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.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Luski.net.Enums;
|
using Luski.net.Enums;
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ namespace Luski.net;
|
|||||||
|
|
||||||
public class API
|
public class API
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
public MainServer MainServer { get; internal set; }
|
public MainServer MainServer { get; internal set; }
|
||||||
|
|
||||||
public bool IsAnyServerLoggedin { 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));
|
IEnumerable<PublicServer> isl = InternalServers.Where(a => (a.Domain == Domain && a.ApiVersion == Version));
|
||||||
if (isl.Any()) return isl.First();
|
if (isl.Any()) return isl.First();
|
||||||
s = await PublicServer.GetServer(this, Domain, Version, Secure);
|
s = await PublicServer.GetServer(Domain, Version, Secure);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -84,7 +86,7 @@ public class API
|
|||||||
{
|
{
|
||||||
DateTime dt = DateTime.UtcNow;
|
DateTime dt = DateTime.UtcNow;
|
||||||
Console.WriteLine("Conecting to main server '{0}' using API {1}.", Domain, Version);
|
Console.WriteLine("Conecting to main server '{0}' using API {1}.", Domain, Version);
|
||||||
MainServer = new(this, Domain, Version)
|
MainServer = new(Domain, Version)
|
||||||
{
|
{
|
||||||
ServerType = ServerType.Main
|
ServerType = ServerType.Main
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,8 @@ namespace Luski.net;
|
|||||||
|
|
||||||
public partial class MainServer : Server
|
public partial class MainServer : Server
|
||||||
{
|
{
|
||||||
internal MainServer(API api, string Domain, string API_Version):
|
internal MainServer(string Domain, string API_Version):
|
||||||
base(api, Domain, API_Version)
|
base(Domain, API_Version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public partial class PublicServer
|
|||||||
stor);
|
stor);
|
||||||
EncryptionHandler.OfflinePublicKey = null!;
|
EncryptionHandler.OfflinePublicKey = null!;
|
||||||
EncryptionHandler.OfflinePrivateKey = null!;
|
EncryptionHandler.OfflinePrivateKey = null!;
|
||||||
API_Handler.IsAnyServerLoggedin = true;
|
//API_Handler.IsAnyServerLoggedin = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -179,7 +179,7 @@ public partial class PublicServer
|
|||||||
throw new Exception(json?.ErrorMessage);
|
throw new Exception(json?.ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_Handler.IsAnyServerLoggedin = true;
|
//API_Handler.IsAnyServerLoggedin = true;
|
||||||
return 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));
|
// _ = await setkey.PostAsync($"{(Secure ? "https" : "http" )}://{Domain}/{ApiVersion}/Keys/SetOfflineKey", new StringContent(EncryptionHandler.OfflinePublicKey));
|
||||||
EncryptionHandler.OfflinePublicKey = null!;
|
EncryptionHandler.OfflinePublicKey = null!;
|
||||||
EncryptionHandler.OfflinePrivateKey = null!;
|
EncryptionHandler.OfflinePrivateKey = null!;
|
||||||
API_Handler.IsAnyServerLoggedin = true;
|
//API_Handler.IsAnyServerLoggedin = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else throw new Exception(json?.ErrorMessage);
|
else throw new Exception(json?.ErrorMessage);
|
||||||
|
|
||||||
API_Handler.IsAnyServerLoggedin = true;
|
//API_Handler.IsAnyServerLoggedin = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,15 +31,15 @@ public partial class PublicServer : Server
|
|||||||
|
|
||||||
public SocketAppUser User { get; private set; } = null!;
|
public SocketAppUser User { get; private set; } = null!;
|
||||||
|
|
||||||
private PublicServer(API api,string Domain, string API_Version, bool Secure = true) :
|
private PublicServer(string Domain, string API_Version, bool Secure = true) :
|
||||||
base(api, Domain, API_Version, Secure)
|
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;
|
DateTime dt = DateTime.UtcNow;
|
||||||
Console.WriteLine("Connecting to public server '{0}' using API {1}.", Domain, API_Version);
|
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;
|
ServerInfo? si = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -19,17 +19,16 @@ namespace Luski.net;
|
|||||||
|
|
||||||
public partial class Server
|
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.Domain = Domain;
|
||||||
this.ApiVersion = API_Version;
|
this.ApiVersion = API_Version;
|
||||||
this.Secure = Secure;
|
this.Secure = Secure;
|
||||||
Storage = new(Domain);
|
Storage = new(Domain);
|
||||||
EncryptionHandler = new(Storage);
|
EncryptionHandler = new(Storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool Secure = true;
|
internal bool Secure = true;
|
||||||
internal string wssurl;
|
internal string wssurl;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user