diff --git a/AMNet.Server/CardPresenter.cs b/AMNet.Server/CardPresenter.cs index 5221c55..2d053a4 100644 --- a/AMNet.Server/CardPresenter.cs +++ b/AMNet.Server/CardPresenter.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.Linq; +using System.Threading; namespace AMNet.Server; @@ -9,9 +10,9 @@ namespace AMNet.Server; /// internal class CardPresenter { - private readonly object _cardLock = new(); + private readonly Lock _cardLock = new(); private StoredCard _currentCard; - + public record StoredCard(byte[] Value, string OriginalValue, long ExpiresAt) { public bool Expired => Environment.TickCount64 >= ExpiresAt; @@ -65,7 +66,7 @@ internal class CardPresenter return null; } } - + var card = new StoredCard(bytes, matrixCode, Environment.TickCount64 + validFor); lock (_cardLock) diff --git a/AMNet.Server/Config.cs b/AMNet.Server/Config.cs index 260df44..954fd87 100644 --- a/AMNet.Server/Config.cs +++ b/AMNet.Server/Config.cs @@ -14,17 +14,17 @@ internal static class Config { GameId = ReadKey(IOSection, "gameId", 4); ServerName = ReadKey(IOSection, "serverName", 26, Environment.MachineName); - + EnableAimeTxt = PInvoke.GetPrivateProfileInt(IOSection, "enableKeyboardMode", 1, ConfigFileName) > 0; AimeTxtPath = ReadKey("aime", "aimePath", PInvoke.MAX_PATH, @"DEVICE\aime.txt"); } - + public static string GameId { get; } public static string ServerName { get; } - + public static bool EnableAimeTxt { get; } public static string AimeTxtPath { get; } - + internal static unsafe string ReadKey(string section, string key, uint maxLength, string @default = null) { // +1 for null terminator diff --git a/AMNet.Server/WebServer.cs b/AMNet.Server/WebServer.cs index 21917cb..e238f5b 100644 --- a/AMNet.Server/WebServer.cs +++ b/AMNet.Server/WebServer.cs @@ -63,7 +63,7 @@ internal static partial class WebServer builder.Services.AddSingleton(); var app = builder.Build(); - + app.UseCors(); app.MapGet("/amnet/info", ServerInfo); @@ -83,7 +83,7 @@ internal static partial class WebServer Config.ServerName, Environment.TickCount64 - startedAt, lastPollAt < 0 ? null : Environment.TickCount64 - lastPollAt); - + return Results.Ok(state); }