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

34 lines
911 B
Rust
Raw Normal View History

2026-01-03 19:17:13 +08:00
#[cfg(target_os = "linux")]
2026-01-02 17:23:24 +08:00
use std::sync::Arc;
2026-01-03 19:17:13 +08:00
#[cfg(target_os = "linux")]
use xiao::app::client::Client;
2026-01-02 09:59:29 +08:00
2026-01-03 19:17:13 +08:00
#[cfg(not(target_os = "linux"))]
fn main() {
println!("This client only works on Linux due to ALSA dependencies.");
}
#[cfg(target_os = "linux")]
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(())
}