use rvoip_sip::{Config, StreamPeer};
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_env_filter(
std::env::var("RUST_LOG").unwrap_or_else(|_| "warn,rvoip_sip_dialog=error".into()),
)
.init();
let mut caller = StreamPeer::with_config(Config::local("caller", 5061)).await?;
println!("Calling custom handler...");
let call_id = caller.invite("sip:custom@127.0.0.1:5060").send().await?;
let handle = caller.coordinator().session(&call_id);
caller.wait_for_answered(handle.id()).await?;
for digit in ['5', '#'] {
sleep(Duration::from_secs(1)).await;
println!("Sending DTMF '{}'", digit);
handle.send_dtmf(digit).await.ok();
}
sleep(Duration::from_secs(2)).await;
println!("Hanging up...");
handle.hangup().await.ok();
caller.wait_for_ended(handle.id()).await.ok();
println!("Done.");
std::process::exit(0);
}