chore: test client call server

This commit is contained in:
Del Wang
2026-01-02 17:37:27 +08:00
parent a2d06958e1
commit c4f7fbec6d
3 changed files with 66 additions and 7 deletions
+15
View File
@@ -69,6 +69,21 @@ impl Client {
}
}
pub async fn call(&self, method: &str, args: Vec<String>) -> Result<RpcResult> {
let (id, rx) = self.rpc.register();
if let Some(conn) = self.conn.lock().await.as_ref() {
conn.send(&ControlPacket::RpcRequest {
id,
method: method.to_string(),
args,
})
.await?;
Ok(rx.await?)
} else {
Err(anyhow::anyhow!("Not connected"))
}
}
async fn handle_packet(
&self,
packet: ControlPacket,