LocalHub class
A complete in-memory DAP/1 hub for local development and tests.
Everything lives in memory — registry, live connections, offline mailboxes, the seen-nonce set — so a hub restart loses undelivered offline mail and nonce memory (docs/dap.md §8.1: hubs are disposable, identities live on the agents).
Constructors
- LocalHub({int port = 0, String bind = 'loopback', String? masterSecret, File? stateFile})
-
portdefaults to 0 = an ephemeral port (tests).fa hub servepasses the well-known 8787 so zero-config clients (ws://127.0.0.1:8787/ws) meet without configuration.masterSecretpassword-protects the hub (docs/dap.md): every WS upgrade must then carry the credential asAuthorization: Bearer
Properties
-
agentIds
→ List<
String> -
Every registered agentId (welcome order) — the standalone e2e runner
reports roster changes so the spec learns both peers' ids.
no setter
-
agentOffline
→ Stream<
String> -
Fires when a live connection for an agent goes away.
no setter
- bind → String
-
The listener scope (issue #402 AC4):
'loopback'(default) binds 127.0.0.1 only;'lan'binds all interfaces so LAN peers — the iOS app above all — can reach the hub. Off by default: a LAN-reachable hub is an explicit host decision.final -
channelMembers
→ Map<
String, Set< String> > -
Channel membership per spec § join (first join creates the channel).
final
-
deliveredTo
→ List<
String> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
hellos
→ Stream<
String> -
no setter
- hellosSeen → int
-
Accepted hellos so far (reconnect/retarget double-loop detection).
no setter
- isProtected → bool
-
True when this hub requires a credential on the WS upgrade.
no setter
-
joins
→ Stream<
HubJoin> -
Fires for every accepted join (deterministic test waits).
no setter
- port → int
-
The port to bind (
0= ephemeral, tests).final - rejectedHellos ↔ int
-
getter/setter pair
-
relayed
→ List<
Map< String, dynamic> > -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → Uri
-
no setter
-
whoisQueries
→ List<
String> -
final
Methods
-
closeAgent(
String agentId) → Future< void> - Force-closes an agent's live connection (network-drop simulation).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pushError(
String agentId, String code, String msg) → void -
Pushes a raw hub
errorframe to an agent's live connection (error-surfacing tests). -
pushMsg(
String agentId, Map< String, dynamic> msg) → void -
Pushes a raw hub
msgframe to an agent's live connection (undecryptable-payload delivery tests). -
start(
) → Future< void> -
stop(
) → Future< void> -
toString(
) → String -
A string representation of this object.
inherited
-
waitForHellos(
int n, {Duration timeout = const Duration(seconds: 5)}) → Future< void> -
Resolves when the hub has seen
nsignature-verified hellos.timeoutbounds the wait — the default 5s suits unit tests; PTY integration tests on loaded runners pass 30s (the CLI's dial rides a colddartVM behind a TUI boot).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited