Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix C: CommandClient API Reference

The CommandClient is available in process_tick via ctx.client. All methods are non-blocking.

MethodSignatureDescription
send(&mut self, topic: &str, data: Value) -> u32Send a request. Returns the transaction_id.
poll(&mut self)Drain all available responses from the WebSocket into the buffer. Called automatically by the framework before each process_tick.
take_response(&mut self, transaction_id: u32) -> Option<CommandMessage>Take a response for a specific transaction_id. Returns None if not yet arrived.
is_pending(&self, transaction_id: u32) -> boolCheck if a request is still awaiting a response.
pending_count(&self) -> usizeNumber of outstanding requests.
response_count(&self) -> usizeNumber of buffered responses ready to be claimed.
drain_stale(&mut self, timeout: Duration) -> Vec<u32>Remove and return transaction_ids that have been pending longer than timeout.

CommandMessage response fields:

FieldTypeDescription
transaction_idu32Matches the ID returned by send()
successboolWhether the request was processed successfully
dataserde_json::ValueThe response payload (on success)
error_messageStringError description (on failure)