refactor(app): make session start terminal
Move live-session startup and its existing diagnostics into the typed Phase-9 owner. GameWindow.OnLoad now ends immediately after that phase, so no callback binding, publication, or allocation can occur after the session becomes active. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
3628aeb520
commit
54244d31f1
11 changed files with 139 additions and 39 deletions
47
src/AcDream.App/Composition/SessionStartComposition.cs
Normal file
47
src/AcDream.App/Composition/SessionStartComposition.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using AcDream.App.Net;
|
||||
|
||||
namespace AcDream.App.Composition;
|
||||
|
||||
internal sealed record SessionStartDependencies(
|
||||
RuntimeOptions Options,
|
||||
Action<string> Log);
|
||||
|
||||
/// <summary>
|
||||
/// Terminal startup phase. Every callback, command target, and frame root is
|
||||
/// already published when this owner asks the canonical session host to start.
|
||||
/// </summary>
|
||||
internal sealed class SessionStartCompositionPhase
|
||||
: ISessionStartCompositionPhase<FrameRootResult>
|
||||
{
|
||||
private readonly SessionStartDependencies _dependencies;
|
||||
|
||||
public SessionStartCompositionPhase(SessionStartDependencies dependencies) =>
|
||||
_dependencies = dependencies
|
||||
?? throw new ArgumentNullException(nameof(dependencies));
|
||||
|
||||
public void Start(FrameRootResult frame)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(frame);
|
||||
LiveSessionStartResult result =
|
||||
frame.SessionHost.Start(_dependencies.Options);
|
||||
Report(result, _dependencies.Log);
|
||||
}
|
||||
|
||||
internal static void Report(
|
||||
LiveSessionStartResult result,
|
||||
Action<string> log)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(result);
|
||||
ArgumentNullException.ThrowIfNull(log);
|
||||
switch (result.Status)
|
||||
{
|
||||
case LiveSessionStartStatus.MissingCredentials:
|
||||
log(
|
||||
"live: ACDREAM_LIVE set but TEST_USER/TEST_PASS missing; skipping");
|
||||
break;
|
||||
case LiveSessionStartStatus.Failed:
|
||||
log($"live: session failed: {result.Error}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1420,18 +1420,9 @@ public sealed class GameWindow :
|
|||
livePresentation,
|
||||
sessionPlayer);
|
||||
|
||||
AcDream.App.Net.LiveSessionStartResult liveStart =
|
||||
frameRoots.SessionHost.Start(_options);
|
||||
switch (liveStart.Status)
|
||||
{
|
||||
case AcDream.App.Net.LiveSessionStartStatus.MissingCredentials:
|
||||
Console.WriteLine(
|
||||
"live: ACDREAM_LIVE set but TEST_USER/TEST_PASS missing; skipping");
|
||||
break;
|
||||
case AcDream.App.Net.LiveSessionStartStatus.Failed:
|
||||
Console.WriteLine($"live: session failed: {liveStart.Error}");
|
||||
break;
|
||||
}
|
||||
new SessionStartCompositionPhase(
|
||||
new SessionStartDependencies(_options, Console.WriteLine))
|
||||
.Start(frameRoots);
|
||||
}
|
||||
|
||||
private void OnUpdate(double dt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue