HttpHost
Category: Acp
Source: http_host.dart
HTTP host for ACP over WebSocket.
Binds an HTTP server to a port, accepts WebSocket upgrades on configurable paths, and spawns one [AcpServer] per connection. All connections share the same [AcpServerDelegate] (so harness state like ServiceLocator initialization is reused), but each connection has its own per-connection session map inside that delegate's implementation.
Multi-tenancy isolation between connections is the delegate's responsibility — the host just hands each WS the JSON-RPC peer adapter.
Classes
AcpHttpHost
Binds an [HttpServer], handles WebSocket upgrades on [path], and runs an [AcpServer] for each connection.
Constructor
AcpHttpHost({
required this.delegateFactory,
this.config = const AcpServerConfig(),
this.path = '/acp',
this.bearerToken,
})Properties
| Property | Type | Description |
|---|---|---|
config | AcpServerConfig | |
path | String | HTTP path that accepts the WebSocket upgrade. Other paths return 404. * accepts any path. |
bearerToken | String? | When non-null, every WebSocket upgrade must present this token in either an Authorization: Bearer <token> header or a ?token=… query parameter. Required for non-loopback binds. |
port | int? get | The bound port (after [start]). Useful for tests that pass 0. |
activeConnections | int get | Number of currently-active WebSocket connections. Useful for tests + observability. |
onConnectionClosed | Stream<void> get | Stream that fires every time a connection closes — useful for tests that want to await teardown. |
diff | var | |
diff | return | |
transport | WebSocketTransport | |
server | AcpServer | |
port | int? get | The bound port (after [start]). Useful for tests that pass 0. |
activeConnections | int get | Number of currently-active WebSocket connections. Useful for tests + observability. |
onConnectionClosed | Stream<void> get | Stream that fires every time a connection closes — useful for tests that want to await teardown. |
Methods
Future<int> start({InternetAddress? address, int port = 3000})
Bind the HTTP server. Returns the bound port. Pass [port]=0 to let the OS pick.
Future<void> stop()
Close the host. Existing connections are forcibly torn down.