refactor(net): converge live session state reset
This commit is contained in:
parent
78a9223b65
commit
4f31a5085f
35 changed files with 1460 additions and 83 deletions
|
|
@ -42,6 +42,31 @@ public sealed class InteractionState
|
|||
|
||||
public bool Clear() => Set(InteractionMode.None);
|
||||
|
||||
/// <summary>
|
||||
/// Publishes the session-reset edge even when the mode is already clear so
|
||||
/// a retry can repair any observer that missed an earlier notification.
|
||||
/// </summary>
|
||||
public void ResetSession()
|
||||
{
|
||||
InteractionMode previous = Current;
|
||||
Current = InteractionMode.None;
|
||||
Action<InteractionModeTransition>? listeners = Changed;
|
||||
if (listeners is null)
|
||||
return;
|
||||
|
||||
var transition = new InteractionModeTransition(previous, InteractionMode.None);
|
||||
List<Exception>? failures = null;
|
||||
foreach (Action<InteractionModeTransition> listener in listeners.GetInvocationList())
|
||||
{
|
||||
try { listener(transition); }
|
||||
catch (Exception error) { (failures ??= []).Add(error); }
|
||||
}
|
||||
if (failures is not null)
|
||||
throw new AggregateException(
|
||||
"One or more interaction-mode reset observers failed.",
|
||||
failures);
|
||||
}
|
||||
|
||||
private bool Set(InteractionMode mode)
|
||||
{
|
||||
if (Current == mode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue