Skip to main content

spawn_web

Function spawn_web 

Source
pub async fn spawn_web(
    ui_state: Arc<Mutex<UiState>>,
    broadcast_tx: Sender<WsMessage>,
    config: WebConfig,
) -> (SocketAddr, Receiver<String>)
Expand description

Spawn the web server on a Tokio task.

Returns the bound address and a receiver for chat messages sent from the browser (via POST /api/chat or {"type":"chat"} WebSocket messages). Read from the receiver in your agent loop to drive conversation turns.

The server runs until the Tokio runtime shuts down.

ยงArguments

  • ui_state โ€” Shared agent state (same instance passed to UiEventHandler).
  • broadcast_tx โ€” Sender half of the WebSocket broadcast channel. Pass the same sender to WebBroadcastHandler::new().
  • config โ€” Server configuration.