fix(galaxy): unify IsConnected with _connected guard; AttachForTests marks connected (review)

This commit is contained in:
Joseph Doherty
2026-06-11 09:16:51 -04:00
parent 43b96441a5
commit 565b77e6cf
2 changed files with 36 additions and 2 deletions
@@ -40,8 +40,12 @@ public sealed class GalaxyMxSession : IAsyncDisposable
_logger = logger ?? NullLogger.Instance;
}
/// <summary>Gets a value indicating whether the session is connected.</summary>
public bool IsConnected => _session is not null;
/// <summary>
/// Gets a value indicating whether a session is currently established. Set <c>true</c> on a
/// successful connect/attach and <c>false</c> after teardown/dispose — tracks the same
/// <c>_connected</c> flag that <see cref="ConnectAsync"/> guards on, so the two never disagree.
/// </summary>
public bool IsConnected => _connected;
/// <summary>
/// Server-side handle returned by MXAccess <c>Register</c>. Zero before
@@ -122,6 +126,7 @@ public sealed class GalaxyMxSession : IAsyncDisposable
ObjectDisposedException.ThrowIf(_disposed, this);
_session = session ?? throw new ArgumentNullException(nameof(session));
_serverHandle = serverHandle;
_connected = true; // an attached session means connected — keeps IsConnected + the ConnectAsync no-op guard consistent.
}
/// <summary>