@@ -19,16 +19,13 @@ use rsip::{
1919 headers:: Route ,
2020 prelude:: { HeadersExt , ToTypedHeader , UntypedHeader } ,
2121 typed:: { CSeq , Contact , Via } ,
22- Header , Param , Request , Response , SipMessage , StatusCode , StatusCodeKind ,
22+ Header , Param , Request , Response , SipMessage , StatusCode ,
2323} ;
2424use std:: sync:: {
2525 atomic:: { AtomicU32 , Ordering } ,
2626 Arc , Mutex ,
2727} ;
28- use tokio:: {
29- sync:: mpsc:: { UnboundedReceiver , UnboundedSender } ,
30- time:: interval,
31- } ;
28+ use tokio:: sync:: mpsc:: { UnboundedReceiver , UnboundedSender } ;
3229use tokio_util:: sync:: CancellationToken ;
3330use tracing:: { debug, info, warn} ;
3431
@@ -180,6 +177,7 @@ pub struct DialogInner {
180177
181178 pub credential : Option < Credential > ,
182179 pub route_set : Mutex < Vec < Route > > ,
180+
183181 pub ( super ) endpoint_inner : EndpointInnerRef ,
184182 pub ( super ) state_sender : DialogStateSender ,
185183 pub ( super ) tu_sender : TransactionEventSender ,
@@ -587,61 +585,6 @@ impl DialogInner {
587585 * old_state = state;
588586 Ok ( ( ) )
589587 }
590-
591- pub ( super ) fn serve_keepalive_options ( dlg_inner : Arc < Self > ) {
592- let keepalive = match dlg_inner. endpoint_inner . option . dialog_keepalive_duration {
593- Some ( k) => k,
594- None => return ,
595- } ;
596- let token = dlg_inner. cancel_token . child_token ( ) ;
597- let dlg_ref = dlg_inner. clone ( ) ;
598-
599- tokio:: spawn ( async move {
600- let mut ticker = interval ( keepalive) ;
601- // skip first tick, which will be reached immediately
602- ticker. tick ( ) . await ;
603- let keepalive_loop = async {
604- loop {
605- ticker. tick ( ) . await ;
606- if !dlg_ref. is_confirmed ( ) {
607- return Ok ( ( ) ) ;
608- }
609- let options = dlg_ref. make_request (
610- rsip:: Method :: Options ,
611- None ,
612- None ,
613- None ,
614- None ,
615- None ,
616- ) ?;
617- let id = dlg_ref. id . lock ( ) . unwrap ( ) . clone ( ) ;
618- match dlg_ref. do_request ( options) . await {
619- Ok ( Some ( resp) ) => match resp. status_code . kind ( ) {
620- StatusCodeKind :: Provisional | StatusCodeKind :: Successful => {
621- continue ;
622- }
623- _ => {
624- info ! ( %id, status = %resp. status_code, "keepalive options failed" ) ;
625- }
626- } ,
627- Ok ( None ) => {
628- continue ;
629- }
630- Err ( _) => { }
631- }
632- dlg_ref
633- . transition ( DialogState :: Terminated ( id, TerminatedReason :: Timeout ) )
634- . ok ( ) ;
635- break ;
636- }
637- Ok :: < ( ) , crate :: Error > ( ( ) )
638- } ;
639- tokio:: select! {
640- _ = token. cancelled( ) => { }
641- _ = keepalive_loop =>{ }
642- } ;
643- } ) ;
644- }
645588}
646589
647590impl std:: fmt:: Display for DialogState {
0 commit comments