Class DirectAgentExecutor
IDbCommandExecuter that tries the direct WebRTC DataChannel transport first and falls back to HttpAgentExecutor transparently if the channel cannot be opened (corporate firewall, STUN unreachable, Agent that doesn't speak the protocol …).
Pattern mirrors the proven path in
ReportmanAI/Reportman.Hub.Client/HubApiClient.DataChannel.cs:
- UseDirectChannel master switch (default true).
- 10-minute cooldown after a failed negotiation, so subsequent queries don't re-pay the open-timeout (~5 s) on each one.
- Per-database pool reuses the warm channel across calls.
- Effective transport surfaced via LastConnectionMode and the ConnectionModeChanged event so a UI chip can bind to it without having to know about WebRTC.
.NET Framework (net48) builds compile this file out — Reportman.DataChannel requires .NET 6+ (SIPSorcery). On net48 consumers get only the HTTP path, identical to the Linux/FPC behaviour of the Delphi engine.
Inherited Members
Namespace: Reportman.Reporting
Assembly: Reportman.Reporting.dll
Syntax
public class DirectAgentExecutor : IDbCommandExecuter, IDisposable
Constructors
View SourceDirectAgentExecutor()
Declaration
public DirectAgentExecutor()
DirectAgentExecutor(string, string, long)
Declaration
public DirectAgentExecutor(string baseUrl, string apiKey, long hubDatabaseId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | baseUrl | |
| string | apiKey | |
| long | hubDatabaseId |
Properties
View SourceApiKey
ApiKey for the database alias when no user is logged in.
Declaration
public string ApiKey { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
BaseUrl
API base URL (same as BaseUrl).
Declaration
public string BaseUrl { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
HubDatabaseId
Identifier of the database on the Hub side.
Declaration
public long HubDatabaseId { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
LastConnectionMode
Effective transport of the most recent Open(IDbCommand). Unknown before any call.
Declaration
public ConnectionMode LastConnectionMode { get; }
Property Value
| Type | Description |
|---|---|
| ConnectionMode |
Token
Bearer JWT for logged-in user calls.
Declaration
public string Token { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
UseDirectChannel
Global kill-switch. Setting this to false at runtime makes
every Open(IDbCommand) call go straight to HTTP, no negotiation
attempt. Useful for diagnostics or forcibly-HTTP integration tests.
Declaration
public bool UseDirectChannel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
View SourceCreateCommand()
Delegates to the inner HTTP executor: both transports speak the same HttpAgentCommand for accumulated parameters, so callers don't need to know which one will execute.
Declaration
public IDbCommand CreateCommand()
Returns
| Type | Description |
|---|---|
| IDbCommand |
Dispose()
Declaration
public void Dispose()
Open(IDbCommand)
Try the direct channel first; on any failure (cooldown active, negotiation failed, channel error mid-query) silently fall back to the inner HTTP path. The caller never sees a "direct channel broke" exception — it sees the data, just over HTTP. The chip is the only visible difference.
Declaration
public DataTable Open(IDbCommand ncommand)
Parameters
| Type | Name | Description |
|---|---|---|
| IDbCommand | ncommand |
Returns
| Type | Description |
|---|---|
| DataTable |
ResetChannelPool()
Drop every warm Direct Channel session and clear the negotiation cooldowns. Call after the user edits a connection (ApiKey / HubDatabaseId) so the next query renegotiates with the new credentials instead of reusing a session opened with the old ones. The warm pool keys sessions by HubDatabaseId, so an ApiKey change on the same database would otherwise keep hitting the stale session until the application is restarted. EvictAllAsync clears the pool synchronously (only the teardown of the old sessions is async), so a fire-and-forget call invalidates the cache immediately.
Declaration
public static void ResetChannelPool()
Events
View SourceConnectionModeChanged
Fired after every Open once the transport is decided.
Declaration
public event Action<ConnectionMode> ConnectionModeChanged
Event Type
| Type | Description |
|---|---|
| Action<ConnectionMode> |