Web panel (like txAdmin) on the game port: login/roles/users, players, kick/ban/op, bans, live console, world reset/backups/restore, settings editor, save ZIP upload/download, start/stop/restart; in-process restart loop; tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
namespace MSCO.Server;
|
||||
|
||||
/// <summary>Die letzten Log-Zeilen im Speicher - für die Live-Konsole im Web-Panel.</summary>
|
||||
public static class LogBuffer
|
||||
{
|
||||
public readonly record struct Line(long Seq, string Time, string Text);
|
||||
|
||||
const int Capacity = 3000;
|
||||
static readonly Queue<Line> lines = new();
|
||||
static readonly object gate = new();
|
||||
static long seq;
|
||||
|
||||
public static long LastSeq { get { lock (gate) return seq; } }
|
||||
|
||||
public static void Add(string time, string text)
|
||||
{
|
||||
lock (gate)
|
||||
{
|
||||
lines.Enqueue(new Line(++seq, time, text));
|
||||
while (lines.Count > Capacity) lines.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Zeilen nach der angegebenen Nummer (höchstens max, die neuesten).</summary>
|
||||
public static List<Line> Since(long after, int max)
|
||||
{
|
||||
lock (gate)
|
||||
{
|
||||
var result = lines.Where(l => l.Seq > after).ToList();
|
||||
return result.Count > max ? result.GetRange(result.Count - max, max) : result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user