improve server clientcount/activity graph on server overview
This commit is contained in:
@ -6,13 +6,19 @@ namespace SharedLibraryCore.Dtos
|
||||
public class ClientHistoryInfo
|
||||
{
|
||||
public long ServerId { get; set; }
|
||||
public List<ClientCountSnapshot> ClientCounts { get; set; }
|
||||
public List<ClientCountSnapshot> ClientCounts { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ClientCountSnapshot
|
||||
{
|
||||
private const int UpdateInterval = 5;
|
||||
public DateTime Time { get; set; }
|
||||
public string TimeString => Time.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
public string TimeString => new DateTime(Time.Year, Time.Month, Time.Day, Time.Hour,
|
||||
Math.Min(59, UpdateInterval * (int)Math.Round(Time.Minute / (float)UpdateInterval)), 0)
|
||||
.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
public int ClientCount { get; set; }
|
||||
public bool ConnectionInterrupted { get;set; }
|
||||
public string Map { get; set; }
|
||||
public string MapAlias { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ namespace SharedLibraryCore.Dtos
|
||||
public int MaxClients { get; set; }
|
||||
public List<ChatInfo> ChatHistory { get; set; }
|
||||
public List<PlayerInfo> Players { get; set; }
|
||||
public PlayerHistory[] PlayerHistory { get; set; }
|
||||
public List<ClientCountSnapshot> ClientCountHistory { get; set; }
|
||||
public ClientHistoryInfo ClientHistory { get; set; }
|
||||
public long ID { get; set; }
|
||||
public bool Online { get; set; }
|
||||
public string ConnectProtocolUrl { get; set; }
|
||||
@ -40,4 +39,4 @@ namespace SharedLibraryCore.Dtos
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using SharedLibraryCore.Dtos;
|
||||
|
||||
namespace SharedLibraryCore.Helpers
|
||||
{
|
||||
public class PlayerHistory
|
||||
{
|
||||
// how many minutes between updates
|
||||
public static readonly int UpdateInterval = 5;
|
||||
|
||||
private readonly DateTime When;
|
||||
|
||||
public PlayerHistory(int cNum)
|
||||
{
|
||||
var t = DateTime.UtcNow;
|
||||
When = new DateTime(t.Year, t.Month, t.Day, t.Hour,
|
||||
Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
|
||||
y = cNum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used by CanvasJS as a point on the x axis
|
||||
/// </summary>
|
||||
public string x => When.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
|
||||
/// <summary>
|
||||
/// Used by CanvasJS as a point on the y axis
|
||||
/// </summary>
|
||||
public int y { get; }
|
||||
|
||||
public ClientCountSnapshot ToClientCountSnapshot()
|
||||
{
|
||||
return new ClientCountSnapshot
|
||||
{
|
||||
ClientCount = y,
|
||||
Time = When
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ namespace SharedLibraryCore
|
||||
EventProcessing = new SemaphoreSlim(1, 1);
|
||||
Clients = new List<EFClient>(new EFClient[64]);
|
||||
Reports = new List<Report>();
|
||||
ClientHistory = new Queue<PlayerHistory>();
|
||||
ClientHistory = new ClientHistoryInfo();
|
||||
ChatHistory = new List<ChatInfo>();
|
||||
NextMessage = 0;
|
||||
CustomSayEnabled = Manager.GetApplicationSettings().Configuration().EnableCustomSayName;
|
||||
@ -97,7 +97,7 @@ namespace SharedLibraryCore
|
||||
public List<Map> Maps { get; protected set; } = new List<Map>();
|
||||
public List<Report> Reports { get; set; }
|
||||
public List<ChatInfo> ChatHistory { get; protected set; }
|
||||
public Queue<PlayerHistory> ClientHistory { get; }
|
||||
public ClientHistoryInfo ClientHistory { get; }
|
||||
public Game GameName { get; set; }
|
||||
|
||||
public string Hostname
|
||||
|
Reference in New Issue
Block a user