namespace SOR.Networking.Abstractions.Transport; /// /// An IClientConnection that has completed the auth handshake successfully. /// /// Created by ConnectionLoop.RunAsync() after GatewayAuthValidator confirms the /// session token is valid. Immutable — properties are set once and never changed. /// /// This is the context object passed to every IMessageHandler. Handlers use it to: /// - Know which user sent the message (UserId, DisplayName) /// - Send replies back to the correct client (Connection.SendBytesAsync) /// /// 'record' in C# generates equality comparison (by value of all properties), /// a ToString() override, and a constructor automatically. The 'sealed' modifier /// means no class can inherit from it. /// public sealed record AuthenticatedConnection( /// The underlying transport connection for sending replies. IClientConnection Connection, /// /// The authenticated user's unique identifier. A GUID stored as a string. /// This is the authoritative identity for all service calls made on behalf /// of this connection. /// string UserId, /// /// The user's display name at the time of authentication. /// Cached here to avoid repeated lookups during the session. /// string DisplayName, /// /// The session token used to authenticate this connection. /// Stored for revocation checks — if the token is invalidated mid-session, /// the connection can be closed. /// string SessionToken );