pub async fn handle_connection<S>(
stream: S,
op_tx: UnboundedSender<ControlOp>,
events: Sender<WorldEvent>,
token: Option<ControlToken>,
) -> Result<()>Expand description
Serve one accepted connection: read newline-delimited requests, dispatch each
to the host via op_tx, and write back its response line. Returns when the
client hangs up or on an I/O error. A malformed request line gets an Error
response and the connection continues.
Generic over the stream so the same logic serves a Unix socket or a Windows named pipe. The accept loop that produces the streams (and owns the socket’s lifecycle) lives with the daemon; this is the reusable per-connection half.