Isolate realtime provider broadcasts from departed peers

This commit is contained in:
Meta Vens 2026-07-19 23:13:23 +01:00
commit 8cac8c9ec7
17 changed files with 68 additions and 4 deletions

View file

@ -217,10 +217,30 @@ public sealed class CultMeshQuicRealtimeServer : IAsyncDisposable
CancellationToken cancellationToken = default)
{
if (frame == null) throw new ArgumentNullException(nameof(frame));
var sends = _clients.Keys.Select(client => client.SendAsync(frame, cancellationToken)).ToArray();
var sends = _clients.Keys.Select(client => SendToConnectedClientAsync(client, frame, cancellationToken)).ToArray();
if (sends.Length > 0) await Task.WhenAll(sends).ConfigureAwait(false);
}
private async Task SendToConnectedClientAsync(
CultMeshQuicRealtimeTransport client,
CultMeshRealtimeFrame frame,
CancellationToken cancellationToken)
{
try
{
await client.SendAsync(frame, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
throw;
}
catch
{
if (_clients.TryRemove(client, out _))
client.Dispose();
}
}
/// <summary>Receives the next client-originated state frame.</summary>
public Task<CultMeshRealtimeFrame> ReceiveAsync(CancellationToken cancellationToken = default) =>
_received.ReceiveAsync(cancellationToken);

View file

@ -49,6 +49,10 @@ advertised mapping when it is actually reachable; otherwise it connects to the
advertised QUIC route. Latest-only receivers must replace pending generations
per body rather than queueing render debt.
Provider broadcast isolates physical peers. A client disconnect or send failure
removes that session without failing the publication tick for healthy clients;
only caller cancellation stops the broadcast operation.
**Derived state:** connector choice, physical endpoint, connection health, and
transport diagnostics. None of these grant provider authority or become content
identity.