Skip to content

Commit 91282bb

Browse files
committed
bump version to 0.4.6 and add support for optional headers in hangup, close, and unsubscribe methods
1 parent fcef15c commit 91282bb

4 files changed

Lines changed: 40 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.4.5"
3+
version = "0.4.6"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"

src/dialog/dialog.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff 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

src/dialog/publication.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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(())

src/dialog/subscription.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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(())

0 commit comments

Comments
 (0)