File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " rsipstack"
3- version = " 0.4.5 "
3+ version = " 0.4.6 "
44edition = " 2021"
55description = " SIP Stack Rust library for building SIP applications"
66license = " MIT"
Original file line number Diff line number Diff line change @@ -1397,13 +1397,17 @@ impl Dialog {
13971397 }
13981398
13991399 pub async fn hangup ( & self ) -> Result < ( ) > {
1400+ self . hangup_with_headers ( None ) . await
1401+ }
1402+
1403+ pub async fn hangup_with_headers ( & self , headers : Option < Vec < rsip:: Header > > ) -> Result < ( ) > {
14001404 match self {
1401- Dialog :: ServerInvite ( d) => d. bye ( ) . await ,
1402- Dialog :: ClientInvite ( d) => d. hangup ( ) . await ,
1403- Dialog :: ServerSubscription ( d) => d. unsubscribe ( ) . await ,
1404- Dialog :: ClientSubscription ( d) => d. unsubscribe ( ) . await ,
1405- Dialog :: ServerPublication ( d) => d. close ( ) . await ,
1406- Dialog :: ClientPublication ( d) => d. close ( ) . await ,
1405+ Dialog :: ServerInvite ( d) => d. bye_with_headers ( headers ) . await ,
1406+ Dialog :: ClientInvite ( d) => d. hangup_with_headers ( headers ) . await ,
1407+ Dialog :: ServerSubscription ( d) => d. unsubscribe_with_headers ( headers ) . await ,
1408+ Dialog :: ClientSubscription ( d) => d. unsubscribe_with_headers ( headers ) . await ,
1409+ Dialog :: ServerPublication ( d) => d. close_with_headers ( headers ) . await ,
1410+ Dialog :: ClientPublication ( d) => d. close_with_headers ( headers ) . await ,
14071411 }
14081412 }
14091413
Original file line number Diff line number Diff line change @@ -65,7 +65,12 @@ impl ClientPublicationDialog {
6565 }
6666
6767 pub async fn close ( & self ) -> Result < ( ) > {
68- let mut headers = vec ! [ Header :: Expires ( 0 . into( ) ) ] ;
68+ self . close_with_headers ( None ) . await
69+ }
70+
71+ pub async fn close_with_headers ( & self , extra_headers : Option < Vec < rsip:: Header > > ) -> Result < ( ) > {
72+ let mut headers = extra_headers. unwrap_or_default ( ) ;
73+ headers. push ( Header :: Expires ( 0 . into ( ) ) ) ;
6974 if let Some ( etag) = self . etag ( ) {
7075 headers. push ( Header :: Other ( "SIP-If-Match" . into ( ) , etag. into ( ) ) ) ;
7176 }
@@ -186,6 +191,16 @@ impl ServerPublicationDialog {
186191 }
187192
188193 pub async fn close ( & self ) -> Result < ( ) > {
194+ self . close_with_headers ( None ) . await
195+ }
196+
197+ pub async fn close_with_headers ( & self , extra_headers : Option < Vec < rsip:: Header > > ) -> Result < ( ) > {
198+ let mut headers = extra_headers. unwrap_or_default ( ) ;
199+ headers. push ( Header :: Expires ( 0 . into ( ) ) ) ;
200+ if let Some ( etag) = self . etag ( ) {
201+ headers. push ( Header :: Other ( "SIP-If-Match" . into ( ) , etag. into ( ) ) ) ;
202+ }
203+ self . request ( Method :: Publish , Some ( headers) , None ) . await ?;
189204 self . inner
190205 . transition ( DialogState :: Terminated ( self . id ( ) , TerminatedReason :: UasBye ) ) ?;
191206 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -32,7 +32,12 @@ impl ClientSubscriptionDialog {
3232 }
3333
3434 pub async fn unsubscribe ( & self ) -> Result < ( ) > {
35- let headers = vec ! [ Header :: Expires ( 0 . into( ) ) ] ;
35+ self . unsubscribe_with_headers ( None ) . await
36+ }
37+
38+ pub async fn unsubscribe_with_headers ( & self , headers : Option < Vec < Header > > ) -> Result < ( ) > {
39+ let mut headers = headers. unwrap_or_default ( ) ;
40+ headers. push ( Header :: Expires ( 0 . into ( ) ) ) ;
3641 self . request ( Method :: Subscribe , Some ( headers) , None ) . await ?;
3742 self . inner
3843 . transition ( DialogState :: Terminated ( self . id ( ) , TerminatedReason :: UacBye ) ) ?;
@@ -158,6 +163,13 @@ impl ServerSubscriptionDialog {
158163 }
159164
160165 pub async fn unsubscribe ( & self ) -> Result < ( ) > {
166+ self . unsubscribe_with_headers ( None ) . await
167+ }
168+
169+ pub async fn unsubscribe_with_headers ( & self , headers : Option < Vec < Header > > ) -> Result < ( ) > {
170+ let mut headers = headers. unwrap_or_default ( ) ;
171+ headers. push ( Header :: Expires ( 0 . into ( ) ) ) ;
172+ self . request ( Method :: Subscribe , Some ( headers) , None ) . await ?;
161173 self . inner
162174 . transition ( DialogState :: Terminated ( self . id ( ) , TerminatedReason :: UasBye ) ) ?;
163175 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments