Appendix C: CommandClient API Reference
The CommandClient is available in process_tick via ctx.client. All methods are non-blocking.
| Method | Signature | Description |
|---|---|---|
send | (&mut self, topic: &str, data: Value) -> u32 | Send 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) -> bool | Check if a request is still awaiting a response. |
pending_count | (&self) -> usize | Number of outstanding requests. |
response_count | (&self) -> usize | Number 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:
| Field | Type | Description |
|---|---|---|
transaction_id | u32 | Matches the ID returned by send() |
success | bool | Whether the request was processed successfully |
data | serde_json::Value | The response payload (on success) |
error_message | String | Error description (on failure) |