Collegamento e motore: correzioni regole-1, regole-2, regole-6, websec-1, websec-5, websec-6, engine-1, engine-2, sched-1

Pagine aperte da Alberto non sono segnali (regole-1); cookie perso fuori sessione = disconnessione (regole-2); pagina a riposo quando Alberto lascia il browser (regole-6); la lease di «Accedi»/«Usa il browser» finisce da sola dopo 2 minuti senza vista remota né finestra (websec-1); ping con scadenza sulla vista remota (websec-5); aperture della vista remota serializzate (websec-6); orologio virtuale senza fine anticipata (engine-1); la sincronizzazione della coda non duplica il compito in corso (engine-2); raccolte in evidenza programmate (sched-1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 00:21:13 +00:00
1 parent 78c92eb2a4
commit aff81dfac9
19 files changed
+1122 -92

No files matched your search

+20 -5
View File
@@ -28,6 +28,15 @@ public static class RemoteViewSocket
/// <summary>Close code when the browser stopped or is restarting.</summary>
public const int CloseBrowserStopped = 4002;
/// <summary>How often the server pings the page.</summary>
public static readonly TimeSpan KeepAliveInterval = TimeSpan.FromSeconds(20);
/// <summary>
/// How long a ping may stay unanswered: a page that vanished without closing (laptop lid, lost Wi-Fi) is dropped
/// then, and with it the «Alberto is driving» lease of its view, instead of when TCP gives up many minutes later.
/// </summary>
public static readonly TimeSpan KeepAliveTimeout = TimeSpan.FromSeconds(30);
public static void Map(IEndpointRouteBuilder endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
@@ -69,15 +78,21 @@ public static class RemoteViewSocket
await using (connection.ConfigureAwait(false))
{
using var socket = await context.WebSockets.AcceptWebSocketAsync(new WebSocketAcceptContext
{
KeepAliveInterval = TimeSpan.FromSeconds(20),
DangerousEnableCompression = false,
}).ConfigureAwait(false);
using var socket = await context.WebSockets.AcceptWebSocketAsync(AcceptContext()).ConfigureAwait(false);
await RunAsync(socket, connection, context.RequestAborted).ConfigureAwait(false);
}
}
/// <summary>
/// Pings with a timeout: with an interval alone ASP.NET Core sends unsolicited pongs and never notices a dead page.
/// </summary>
internal static WebSocketAcceptContext AcceptContext() => new()
{
KeepAliveInterval = KeepAliveInterval,
KeepAliveTimeout = KeepAliveTimeout,
DangerousEnableCompression = false,
};
/// <summary>Pumps one view until either side closes it.</summary>
internal static async Task RunAsync(WebSocket socket, IRemoteViewConnection connection, CancellationToken aborted)
{