Logo FSBarV1_Archived

ScriptingHub Module

 The hub's gRPC scripting service — fans `SessionManager.Frames` out
 to every connected client on an independent bounded channel,
 isolates slow / dead clients, and exposes unary RPCs for command
 submission, status queries, and UnitDef lookups (feature
 035-central-gui-hub US7).

 Fan-out design (research.md R3):
   * One internal subscriber to `SessionManager.Frames`.
   * Per-client `System.Threading.Channels.BoundedChannel`
     of configurable capacity (default 16) with
     `BoundedChannelFullMode.DropOldest`. Slow / stuck clients cannot
     back-pressure the producer or other consumers.
   * Drop counter increments whenever the per-client channel is at
     capacity at enqueue time. When cumulative drops reach
     `MaxCumulativeDrops` (default 32) the client is detached with
     `HubEvents.ScriptingClientDetached(OverflowDropLimit)`.

Types

Type Description

ConnectedClientInfo

Rolled-up roster projection of one connected client for the gRPC `GetSessionStatus` response and the Settings tab's client list.

ScriptingHubOptions

Tunables surfaced on the public constructor so tests can pin capacity + drop threshold.

ScriptingService

 The hub-side gRPC service implementation. Constructed once per
 hub process; registered into the Kestrel host via
 `app.MapGrpcService()` in `Program.fs`.

 Constructor dependencies:
   * `sessions` — the hub's one-and-only `SessionManager`.
   * `events` — hub event sink for `ScriptingClient{Connected,Detached}`
      and `DiagnosticsLine` emissions.
   * `unitDefs` — thunk that returns the *currently* loaded
      `UnitDefCache`. Caller threads a closure that reads from
      the active `SessionManager.State.BarClient.GameState.UnitDefs`
      when running, else a cached / empty fallback.
   * `install` / `bundled` / `port` — filled into
     `GetSessionStatusResponse`.
   * `state` — authoritative hub-UI state store (feature 040).
     Lobby-related RPCs (`ConfigureLobby`, `LaunchSession`) read
     and write through this store so the local GUI and gRPC
     clients never drift.
   * `log` — feature-042 Hub log bus. `StreamHubLog` attaches to
     this; every emit site reads back through it. Additive to the
     feature-040 constructor.
   * `opts` — fan-out tunables.

Functions and values

Function or value Description

defaults

Full Usage: defaults

Returns: ScriptingHubOptions

Default tunables: `FrameBufferCapacity = 16`, `MaxCumulativeDrops = 32`.

Returns: ScriptingHubOptions

Type something to start searching.