Luski.Net/Luski.net/API.cs

36 lines
1.1 KiB
C#
Raw Normal View History

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;
}
}