mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-06 22:50:30 -04:00
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:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
87
server/FSO.Server.Domain/Domain/Shards.cs
Executable file
87
server/FSO.Server.Domain/Domain/Shards.cs
Executable file
|
@ -0,0 +1,87 @@
|
|||
using FSO.Common.Domain.Shards;
|
||||
using FSO.Server.Database.DA;
|
||||
using FSO.Server.Protocol.CitySelector;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FSO.Server.Domain
|
||||
{
|
||||
public class Shards : IShardsDomain
|
||||
{
|
||||
private List<ShardStatusItem> _Shards = new List<ShardStatusItem>();
|
||||
private IDAFactory _DbFactory;
|
||||
private DateTime _LastPoll;
|
||||
|
||||
public Shards(IDAFactory factory)
|
||||
{
|
||||
_DbFactory = factory;
|
||||
Poll();
|
||||
}
|
||||
|
||||
public List<ShardStatusItem> All
|
||||
{
|
||||
get{
|
||||
return _Shards;
|
||||
}
|
||||
}
|
||||
|
||||
public int? CurrentShard
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new Exception("CurrentShard not avaliable in server domain");
|
||||
}
|
||||
}
|
||||
|
||||
public void AutoUpdate()
|
||||
{
|
||||
Task.Delay(60000).ContinueWith(x =>
|
||||
{
|
||||
try{
|
||||
Poll();
|
||||
}catch(Exception ex){
|
||||
}
|
||||
AutoUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Poll()
|
||||
{
|
||||
_LastPoll = DateTime.UtcNow;
|
||||
|
||||
using (var db = _DbFactory.Get())
|
||||
{
|
||||
_Shards = db.Shards.All().Select(x => new ShardStatusItem()
|
||||
{
|
||||
Id = x.shard_id,
|
||||
Name = x.name,
|
||||
Map = x.map,
|
||||
Rank = x.rank,
|
||||
Status = (Server.Protocol.CitySelector.ShardStatus)(byte)x.status,
|
||||
PublicHost = x.public_host,
|
||||
InternalHost = x.internal_host,
|
||||
VersionName = x.version_name,
|
||||
VersionNumber = x.version_number,
|
||||
UpdateID = x.update_id
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public ShardStatusItem GetById(int id)
|
||||
{
|
||||
return _Shards.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
public ShardStatusItem GetByName(string name)
|
||||
{
|
||||
return _Shards.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue