refactor(net): cut GameWindow over to session owner

This commit is contained in:
Erik 2026-07-21 12:37:22 +02:00
parent 783ef1d6db
commit 6a5d9e2e6a
5 changed files with 363 additions and 268 deletions

View file

@ -216,7 +216,6 @@ public sealed class LiveSessionController : IDisposable
private SessionScope? _retiredScope;
private ILiveSessionLifecycleHost? _pendingInitialResetHost;
private PendingOperation? _pendingOperation;
private WorldSession? _legacySession;
private int _operationDepth;
private bool _inWorld;
private bool _disposeRequested;
@ -236,12 +235,9 @@ public sealed class LiveSessionController : IDisposable
public WorldSession? CurrentSession
{
get { lock (_gate) return _scope?.Session ?? _legacySession; }
get { lock (_gate) return _scope?.Session; }
}
/// <summary>Temporary Slice-3 compatibility alias; removed at GameWindow cutover.</summary>
public WorldSession? Session => CurrentSession;
public ICommandBus Commands
{
get
@ -319,11 +315,6 @@ public sealed class LiveSessionController : IDisposable
{
if (_disposed)
return;
if (_legacySession is not null && _scope is null)
{
_legacySession.Tick();
return;
}
if (!_inWorld || _scope is null || _operationDepth != 0)
return;
@ -629,11 +620,6 @@ public sealed class LiveSessionController : IDisposable
private void DisposeCore()
{
StopCore();
if (_legacySession is { } legacy)
{
_operations.DisposeSession(legacy);
_legacySession = null;
}
_disposed = true;
}
@ -649,40 +635,4 @@ public sealed class LiveSessionController : IDisposable
throw new ObjectDisposedException(nameof(LiveSessionController));
}
// Temporary compatibility surface for Slice 3 Commit E. The complete
// controller above is exercised independently before GameWindow cuts over.
public WorldSession? CreateAndWire(RuntimeOptions options, Action<WorldSession> wireEvents)
{
ArgumentNullException.ThrowIfNull(options);
ArgumentNullException.ThrowIfNull(wireEvents);
lock (_gate)
{
ThrowIfDisposing();
if (!options.LiveMode)
return null;
if (string.IsNullOrEmpty(options.LiveUser) || string.IsNullOrEmpty(options.LivePass))
{
Console.WriteLine(
"live: ACDREAM_LIVE set but TEST_USER/TEST_PASS missing; skipping");
return null;
}
try
{
IPEndPoint endpoint = _operations.ResolveEndpoint(options.LiveHost, options.LivePort);
Console.WriteLine($"live: connecting to {endpoint} as {options.LiveUser}");
_legacySession = _operations.CreateSession(endpoint);
wireEvents(_legacySession);
return _legacySession;
}
catch (Exception error)
{
Console.WriteLine($"live: session setup failed: {error.Message}");
if (_legacySession is not null)
_operations.DisposeSession(_legacySession);
_legacySession = null;
return null;
}
}
}
}