using Microsoft.AspNetCore.Http.Connections;
namespace AyCode.Services.SignalRs;
///
/// Options for a client-side SignalR HubConnection, designed to be bindable from
/// configuration (appsettings.json) via services.Configure<AcHubConnectionOptions>(...).
/// Applied to an IHubConnectionBuilder via
/// .
///
/// Most properties are nullable — when null the underlying SignalR / Microsoft default
/// is kept (the framework is non-opinionated). Resilience flags default to sensible modern values
/// (auto-reconnect on). Override in code or configuration.
///
/// Precedence (low → high): property initializer → services.Configure<T>(section)
/// → services.Configure<T>(action).
///
public sealed class AcHubConnectionOptions
{
/// Target hub URL — absolute, including the hub path (e.g. "https://host/fbHub").
public string Url { get; set; } = "";
// --- HttpConnectionOptions (applied via WithUrl) ---
/// Transport(s) to negotiate. null → Microsoft default (WebSockets | LongPolling | ServerSentEvents).
public HttpTransportType? Transports { get; set; }
/// Max outbound transport buffer (bytes). null → Microsoft default (~64 KB).
public int? TransportMaxBufferSize { get; set; }
/// Max application-level send buffer (bytes). null → Microsoft default (~64 KB).
public int? ApplicationMaxBufferSize { get; set; }
/// WebSocket close handshake timeout. null → Microsoft default (5 s).
public TimeSpan? CloseTimeout { get; set; }
/// Skip negotiation (WebSockets-only setups). null → Microsoft default (false).
public bool? SkipNegotiation { get; set; }
// --- Connection-level ---
/// Client-side keep-alive ping interval. null → SignalR default (15 s).
public TimeSpan? KeepAliveInterval { get; set; }
/// Server timeout (no-data threshold to declare the connection dead). null → SignalR default (30 s).
public TimeSpan? ServerTimeout { get; set; }
// --- Resilience (framework defaults — opinionated toward modern apps) ---
/// Enable WithAutomaticReconnect(). Default: true.
public bool UseAutomaticReconnect { get; set; } = true;
/// Enable WithStatefulReconnect() (SignalR 8+). Default: false (opt-in — requires server support).
public bool UseStatefulReconnect { get; set; } = false;
}