pub fn spawn_peer_command_task<W>(
command_rx: Receiver<ClientCommand>,
protocol: Arc<dyn Server>,
state: Arc<AppState>,
server_id: ServerId,
connection_id: u32,
write_half: Arc<Mutex<W>>,
status_tx: UnboundedSender<String>,
)Expand description
Drive a connection’s command channel until it closes. The worker is also owned by its connection, so either peer close or server teardown cancels blocked work.
Runs as its own task: unlike the client loops, a server connection task
blocks in read() without a select, and injected sends must not wait for
the peer to talk first. Writes are safe against the reader’s own responses
because both go through the same Arc<Mutex<WriteHalf>>.