Removed NioTSO client and server

- NioTSO client isn't needed because we're using RayLib
- Added FreeSO's API server to handle most backend operations
This commit is contained in:
Tony Bark 2024-05-01 02:55:43 -04:00
parent f12ba1502b
commit 22191ce648
591 changed files with 53264 additions and 3362 deletions

View file

@ -0,0 +1,28 @@
using System;
namespace FSO.Server.Database.DA.Hosts
{
public class DbHost
{
public string call_sign { get; set; }
public DbHostRole role { get; set; }
public DbHostStatus status { get; set; }
public string internal_host { get; set; }
public string public_host { get; set; }
public DateTime time_boot { get; set; }
public int? shard_id { get; set; }
}
public enum DbHostRole
{
city,
lot,
task
}
public enum DbHostStatus
{
up,
down
}
}

View file

@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace FSO.Server.Database.DA.Hosts
{
public interface IHosts
{
IEnumerable<DbHost> All();
DbHost Get(string call_sign);
void CreateHost(DbHost host);
void SetStatus(string call_sign, DbHostStatus status);
}
}

View file

@ -0,0 +1,49 @@
using Dapper;
using System;
using System.Collections.Generic;
namespace FSO.Server.Database.DA.Hosts
{
public class SqlHosts : AbstractSqlDA, IHosts
{
public SqlHosts(ISqlContext context) : base(context)
{
}
public IEnumerable<DbHost> All()
{
return Context.Connection.Query<DbHost>("SELECT * FROM fso_hosts");
}
public void CreateHost(DbHost host)
{
Context.Connection.Execute(
"REPLACE INTO fso_hosts (call_sign, role, status, internal_host, public_host, time_boot, shard_id) " +
"VALUES (@call_sign, @role, @status, @internal_host, @public_host, @time_boot, @shard_id)",
new
{
call_sign = host.call_sign,
role = host.role.ToString(),
status = host.status.ToString(),
internal_host = host.internal_host,
public_host = host.public_host,
time_boot = host.time_boot,
shard_id = host.shard_id
}
);
}
public DbHost Get(string call_sign)
{
throw new NotImplementedException();
}
public void SetStatus(string call_sign, DbHostStatus status)
{
Context.Connection.Execute("UPDATE fso_hosts SET status = @status WHERE call_sign = @call_sign", new {
call_sign = call_sign,
status = status.ToString()
});
}
}
}