Path: redb-route/redb.Route.SignalR/SignalREndpointOptions.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.SignalR/SignalREndpointOptions.cs
----
using redb.Route.Core;
namespace redb.Route.SignalR;
///
/// Options for the SignalR endpoint. Bound from URI parameters via reflection.
/// URI format: signalr:host:port/hubPath?mode=Client&inOut=true&messagePack=true
///
public class SignalREndpointOptions : EndpointOptions
{
// ── Connection ──────────────────────────────────────
/// Bind/connect host. Parsed from URI path. Default: 0.0.0.0.
public string Host { get; set; } = "0.0.0.0";
/// Bind/connect port. Parsed from URI path. Default: 5000.
public int Port { get; set; } = 5000;
// ── Dispatch ────────────────────────────────────────
///
/// Producer mode: Client (HubConnection to remote) or Server (IHubContext broadcast).
/// Ignored for consumer. Default: Client.
///
public SignalRMode Mode { get; set; } = SignalRMode.Client;
///
/// Hub method name. For consumer: filter invocations to this method only.
/// For producer: target method to invoke/send. If null, taken from exchange header.
///
public string? Method { get; set; }
// ── Groups ──────────────────────────────────────────
///
/// Default group name. If set, OnConnectedAsync automatically adds the connection to this group.
///
public string? DefaultGroup { get; set; }
// ── Exchange ────────────────────────────────────────
///
/// If true, the consumer returns exchange Out body as the hub method return value (InOut pattern).
/// Default: false.
///
public bool InOut { get; set; }
// ── Bridge ──────────────────────────────────────────
///
/// When true (default), client-mode producer calls the bridge hub entry point
/// Invoke(method, args) — for connecting to our .
/// When false, producer calls the hub method directly by name — for connecting to
/// external (third-party) SignalR hubs that expose real named methods.
///
public bool Bridge { get; set; } = true;
// ── Transport ───────────────────────────────────────
/// Preferred transport for client connections. Default: WebSockets.
public SignalRTransport Transport { get; set; } = SignalRTransport.WebSockets;
/// Use MessagePack protocol instead of JSON. Default: false.
public bool MessagePack { get; set; }
// ── Producer (client mode) ──────────────────────────
/// Auto-reconnect on disconnect (client mode). Default: false.
public bool Reconnect { get; set; }
/// Interval between reconnect attempts in milliseconds (client mode). Default: 5000.
public int ReconnectInterval { get; set; } = 5_000;
/// Maximum reconnect attempts. 0 = unlimited. Default: 0.
public int MaxReconnectAttempts { get; set; }
// ── Producer (server mode) ──────────────────────────
///
/// Default target for server-mode producer: All, Group, User, Connection.
/// Can be overridden per-exchange via signalR.Target header. Default: "All".
///
public string TargetType { get; set; } = "All";
/// Default group for server-mode producer. Overridden by signalR.Group header.
public string? TargetGroup { get; set; }
// ── TLS ─────────────────────────────────────────────
/// Enable TLS. Default: false.
public bool Ssl { get; set; }
/// Path to PFX certificate file for TLS (consumer/server).
public string? SslCertPath { get; set; }
/// Password for the PFX certificate.
[Sensitive]
public string? SslCertPassword { get; set; }
///
/// Client-mode producer only: accept any server certificate, including a self-signed one.
/// Off by default and never implied by another option — earlier this fired whenever
/// ssl=false, which silently disabled validation for the whole transport.
///
public bool TrustAllCertificates { get; set; }
///
/// Named from the route registry. Lets the access token
/// and TLS certificate password live in the registry instead of the endpoint URI, so they
/// never reach logs or dashboards.
///
[RegistryReference(typeof(SignalRConnectionFactory))]
public string? ConnectionFactory { get; set; }
// ── Auth ────────────────────────────────────────────
/// Access token for client authentication (JWT). Used by producer in client mode.
[Sensitive]
public string? AccessToken { get; set; }
// ── Admission limits ───────────────────────────────────────────
///
/// Maximum hub connections this endpoint accepts (server mode). 0 (default) = unlimited.
/// A connection over the limit is aborted at OnConnected — before the Connected lifecycle
/// event reaches the pipeline — and counted in the endpoint's Rejected. SignalR concurrency
/// is connections × invocations, so this is the coarse lever;
/// is the fine one.
///
public int MaxConnections { get; set; }
///
/// SignalR's own MaximumParallelInvocationsPerClient: how many hub method calls ONE
/// client may run in parallel. 0 (default) = SignalR's default (1, i.e. per-client serial).
///
public int MaxParallelInvocationsPerClient { get; set; }
///
public override void Validate()
{
if (Port is < 0 or > 65535)
throw new ArgumentException("Port must be between 0 and 65535.");
if (ReconnectInterval <= 0)
throw new ArgumentException("ReconnectInterval must be > 0.");
if (MaxReconnectAttempts < 0)
throw new ArgumentException("MaxReconnectAttempts must be >= 0.");
if (MaxConnections < 0)
throw new ArgumentException("maxConnections must be >= 0 (0 = unlimited).");
if (MaxParallelInvocationsPerClient < 0)
throw new ArgumentException("maxParallelInvocationsPerClient must be >= 0 (0 = SignalR default).");
}
}