use std::time::{Duration, SystemTime, UNIX_EPOCH};
use macula_rust::{cbor::Value, connection, identity::KeyPair, transport::Trust};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let identity = KeyPair::generate_with_default_puzzle();
let mut session = connection::connect(
"station-de-frankfurt.macula.io",
4433,
Trust::WebPki,
&identity,
)
.await?;
let now_ms = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() as i128;
let response = session
.call(
"io.macula.echo",
[0u8; 32], Value::Text("hello".into()),
now_ms + 5_000, &identity,
Duration::from_secs(5),
)
.await?;
println!("{response:?}");
Ok(())
}