JacobTech
106d0d6078
• A lot of work needs to be done to make sure this works. • I already know this push won't work, but it will build. • I need to come up with a new way of storing local info. This will also bee needed to fix the very broken key system in this rushed commit.
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Luski.net.Structures.Main;
|
|
using Luski.net.Structures.Public;
|
|
|
|
namespace Luski.net;
|
|
|
|
public class API
|
|
{
|
|
public Server<MainSocketAppUser> MainServer { get; internal set; }
|
|
internal List<Server<PublicSocketAppUser>> InternalServers { get; } = new();
|
|
public IReadOnlyList<Server<PublicSocketAppUser>> LoadedServers => InternalServers.AsReadOnly();
|
|
|
|
public Server<PublicSocketAppUser> GetPublicServer(string Domain, string Version = "v1")
|
|
{
|
|
IEnumerable<Server<PublicSocketAppUser>> isl = InternalServers.Where(a => (a.Domain == Domain && a.ApiVersion == Version));
|
|
if (isl.Any()) return isl.First();
|
|
Server<PublicSocketAppUser> s = new()
|
|
{
|
|
Domain = Domain,
|
|
ApiVersion = Version,
|
|
};
|
|
InternalServers.Add(s);
|
|
return s;
|
|
}
|
|
|
|
public Server<MainSocketAppUser> GetMainServer(string Domain, string Version = "v1")
|
|
{
|
|
MainServer = new()
|
|
{
|
|
Domain = Domain,
|
|
ApiVersion = Version,
|
|
};
|
|
return MainServer;
|
|
}
|
|
} |