From 7aa211a8d7ae2efeebd9362699a1aea4b5690e3d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 6 Jul 2024 17:37:35 +0200 Subject: start on sdp impl --- examples/server.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'examples/server.rs') diff --git a/examples/server.rs b/examples/server.rs index 60a2b33..b58557a 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -9,12 +9,13 @@ use sip::{ method::Method, response::Response, status::Status, + uri::Uri, }, transaction::TransactionUser, - transport::tcp::TcpTransport, + transport::{tcp::TcpTransport, udp::UdpTransport}, }; use tokio::{ - net::{TcpListener, TcpStream}, + net::{TcpListener, TcpStream, UdpSocket}, spawn, }; @@ -23,6 +24,7 @@ async fn main() -> Result<()> { env_logger::init_from_env("LOG"); let listener = TcpListener::bind("0.0.0.0:5060").await?; info!("tcp listener bound to {}", listener.local_addr().unwrap()); + loop { let (stream, addr) = listener.accept().await?; info!("connect {addr}"); @@ -51,11 +53,17 @@ async fn handle_client(stream: TcpStream, addr: SocketAddr) -> Result<()> { Response { status: Status::Ok, headers: HeaderMap::new() - .add(Contact(format!(";expires=600"))) - .add(From(to.0)) - .add(To(from.0)) - .add(UserAgent("siptest v0.1.0".to_string())) - .add(ContentLength(0)), + .add(Contact { + display_name: None, + uri: Uri { + content: format!("sip:username@{addr}"), + }, + params: ";expires=600".to_string(), + }) + .add(to) + .add(from) + .add(UserAgent("siptest v0.1.0".to_string())), + body: String::new(), }, ) .await?; -- cgit v1.2.3-70-g09d2