add check context events

This commit is contained in:
2024-11-08 07:36:46 +01:00
parent a7a3cfa683
commit 2e420ad902
3 changed files with 18 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ public class ApiServer(string apiUrl) : IApiServer
protected readonly HttpListener httpListener = new();
public event OnCheckAuthenticationEventHandler? OnCheckAuthentication;
public event OnCheckContextEventHandler? OnCheckContext;
public event OnCheckContextEventHandler? OnCheckContextCompleted;
protected record PrivateApiResult(ApiResult Original, string? ResultJson);
@@ -104,6 +106,7 @@ public class ApiServer(string apiUrl) : IApiServer
Receive();
// Check context
OnCheckContext?.Invoke(this, new(context));
try
{
CheckContext(context);
@@ -114,6 +117,10 @@ public class ApiServer(string apiUrl) : IApiServer
if (DebugMode)
throw;
}
finally
{
OnCheckContextCompleted?.Invoke(this, new(context));
}
// Listen for new request
if (!AllowMultipleRequests)