Files
open-xiaoai/packages/client-v2/src/bin/client.rs
T

26 lines
704 B
Rust
Raw Normal View History

2026-01-02 17:23:24 +08:00
use xiao::app::client::Client;
use std::sync::Arc;
2026-01-02 09:59:29 +08:00
#[tokio::main]
2026-01-02 17:23:24 +08:00
async fn main() -> anyhow::Result<()> {
let client = Arc::new(Client::new());
2026-01-02 17:37:27 +08:00
let c = client.clone();
tokio::spawn(async move {
if let Err(e) = c.run().await {
eprintln!("Client error: {}", e);
}
});
// Wait for connection
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
println!("Testing RPC call to server...");
match client.call("hello", vec!["world".to_string()]).await {
Ok(res) => println!("Server RPC response: {}", res.stdout),
Err(e) => eprintln!("Server RPC call failed: {}", e),
}
tokio::signal::ctrl_c().await?;
2026-01-02 09:59:29 +08:00
Ok(())
}