Skip to main content

ClientInviteDialog

Struct ClientInviteDialog 

Source
pub struct ClientInviteDialog { /* private fields */ }
Expand description

Client-side INVITE Dialog (UAC)

ClientInviteDialog represents a client-side INVITE dialog in SIP. This is used when the local user agent acts as a User Agent Client (UAC) and initiates an INVITE transaction to establish a session with a remote party.

§Key Features

  • Session Initiation - Initiates INVITE transactions to establish calls
  • In-dialog Requests - Sends UPDATE, INFO, OPTIONS within established dialogs
  • Session Termination - Handles BYE and CANCEL for ending sessions
  • Re-INVITE Support - Supports session modification via re-INVITE
  • Authentication - Handles 401/407 authentication challenges
  • State Management - Tracks dialog state transitions

§Dialog Lifecycle

  1. Creation - Dialog created when sending INVITE
  2. Early State - Receives provisional responses (1xx)
  3. Confirmed - Receives 2xx response and sends ACK
  4. Active - Can send in-dialog requests (UPDATE, INFO, etc.)
  5. Termination - Sends BYE or CANCEL to end session

§Examples

§Basic Call Flow

// After dialog is established:

// Send an UPDATE request
let response = dialog.update(None, Some(new_sdp_body)).await?;

// Send INFO request
let response = dialog.info(None, Some(info_body)).await?;

// End the call
dialog.bye().await?;

§Session Modification

// Modify session with re-INVITE
let headers = vec![
    rsip::Header::ContentType("application/sdp".into())
];
let response = dialog.reinvite(Some(headers), Some(new_sdp)).await?;

if let Some(resp) = response {
    if resp.status_code == rsip::StatusCode::OK {
        println!("Session modified successfully");
    }
}

§Thread Safety

ClientInviteDialog is thread-safe and can be cloned and shared across tasks. All operations are atomic and properly synchronized.

Implementations§

Source§

impl ClientInviteDialog

Source

pub fn id(&self) -> DialogId

Get the dialog identifier

Returns the unique DialogId that identifies this dialog instance. The DialogId consists of Call-ID, from-tag, and to-tag.

Source

pub fn state(&self) -> DialogState

Source

pub fn from_inner(inner: Arc<DialogInner>) -> Self

Source

pub fn snapshot(&self) -> DialogSnapshot

Source

pub fn cancel_token(&self) -> &CancellationToken

Get the cancellation token for this dialog

Returns a reference to the CancellationToken that can be used to cancel ongoing operations for this dialog.

Source

pub async fn bye(&self) -> Result<()>

Send a BYE request to terminate the dialog.

Thin wrapper over bye_with_headers(None).

// End an established call
dialog.bye().await?;
Source

pub async fn bye_with_headers(&self, headers: Option<Vec<Header>>) -> Result<()>

Send a BYE request with custom headers to terminate the dialog.

This is the low-level variant used to add SIP headers (e.g. Reason) to the outgoing BYE request.

The dialog must be in Confirmed state for BYE to be sent; otherwise this method is a no-op.

§Parameters
  • headers - Optional extra SIP headers to include in the BYE request.
§Returns
  • Ok(()) - BYE was sent successfully or dialog is not confirmed.
  • Err(Error) - Failed to build/send BYE request.
Source

pub async fn bye_with_reason(&self, reason: String) -> Result<()>

Send a BYE request with a SIP Reason header.

Convenience wrapper over bye_with_headers() that adds: Reason: <reason>.

Typical values:

  • SIP;cause=804;text="MEDIA_TIMEOUT"
  • Q.850;cause=16;text="Normal call clearing"
§Parameters
  • reason - Value of the Reason header (without the Reason: name).
Source

pub async fn hangup(&self) -> Result<()>

Hang up the call

If the dialog is confirmed, send a BYE request to terminate the call. If the dialog is not confirmed, send a CANCEL request to cancel the call.

Thin wrapper over hangup_with_headers(None).

Source

pub async fn hangup_with_headers( &self, headers: Option<Vec<Header>>, ) -> Result<()>

Hang up the call with custom headers.

If the dialog is still in early phase and can be canceled, this sends CANCEL. Headers are not attached to the CANCEL request by default.

If the dialog is confirmed, this sends BYE and attaches the provided headers.

§Parameters
  • headers - Optional extra SIP headers to include when BYE is used.
Source

pub async fn hangup_with_reason(&self, reason: String) -> Result<()>

Hang up the call and attach a SIP Reason header when BYE is used.

Convenience wrapper over hangup_with_headers() that adds: Reason: <reason>.

§Parameters
  • reason - Value of the Reason header used for BYE.
Source

pub async fn cancel(&self) -> Result<()>

Send a CANCEL request to cancel an ongoing INVITE

Sends a CANCEL request to cancel an INVITE transaction that has not yet been answered with a final response. This is used to abort call setup before the call is established.

§Returns
  • Ok(()) - CANCEL was sent successfully
  • Err(Error) - Failed to send CANCEL request
§Examples
// Cancel an outgoing call before it's answered
dialog.cancel().await?;
Source

pub async fn reinvite( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send a re-INVITE request to modify the session

Sends a re-INVITE request within an established dialog to modify the session parameters (e.g., change media, add/remove streams). This can only be called for confirmed dialogs.

§Parameters
  • headers - Optional additional headers to include
  • body - Optional message body (typically new SDP)
§Returns
  • Ok(Some(Response)) - Response to the re-INVITE
  • Ok(None) - Dialog not confirmed, no request sent
  • Err(Error) - Failed to send re-INVITE
§Examples
let new_sdp = b"v=0\r\no=- 123 456 IN IP4 192.168.1.1\r\n...";
let response = dialog.reinvite(None, Some(new_sdp.to_vec())).await?;
Source

pub async fn update( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send an UPDATE request to modify session parameters

Sends an UPDATE request within an established dialog to modify session parameters without the complexity of a re-INVITE. This is typically used for smaller session modifications.

§Parameters
  • headers - Optional additional headers to include
  • body - Optional message body (typically SDP)
§Returns
  • Ok(Some(Response)) - Response to the UPDATE
  • Ok(None) - Dialog not confirmed, no request sent
  • Err(Error) - Failed to send UPDATE
§Examples
let response = dialog.update(None, Some(sdp_body)).await?;
Source

pub async fn info( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send an INFO request for mid-dialog information

Sends an INFO request within an established dialog to exchange application-level information. This is commonly used for DTMF tones, but can carry any application-specific data.

§Parameters
  • headers - Optional additional headers to include
  • body - Optional message body (application-specific data)
§Returns
  • Ok(Some(Response)) - Response to the INFO
  • Ok(None) - Dialog not confirmed, no request sent
  • Err(Error) - Failed to send INFO
§Examples
// Send DTMF tone
let dtmf_body = b"Signal=1\r\nDuration=100\r\n";
let headers = vec![
    rsip::Header::ContentType("application/dtmf-relay".into())
];
let response = dialog.info(Some(headers), Some(dtmf_body.to_vec())).await?;
Source

pub async fn options( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Source

pub async fn request( &self, method: Method, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send a generic in-dialog request

This method allows sending any SIP request within the dialog. It automatically handles CSeq increment, Call-ID, From/To tags, and Route set.

Source

pub async fn notify( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send a NOTIFY request

Source

pub async fn refer( &self, refer_to: Uri, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send a REFER request

Sends a REFER request to transfer the call to another destination.

§Parameters
  • refer_to - The URI to refer to (Refer-To header value)
  • headers - Optional additional headers
  • body - Optional message body
Source

pub async fn notify_refer( &self, status: StatusCode, sub_state: &str, ) -> Result<Option<Response>>

Send a REFER progress notification (RFC 3515)

This is used by the REFER recipient to notify the sender about the progress of the referred action.

§Parameters
  • status - The status of the referred action (e.g., 100 Trying, 200 OK)
  • sub_state - The subscription state (e.g., “active”, “terminated;reason=noresource”)
Source

pub fn as_subscription(&self) -> ClientSubscriptionDialog

Convert this INVITE dialog to a subscription dialog

This is useful for handling implicit subscriptions created by REFER.

Source

pub async fn message( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>

Send a MESSAGE request

Sends an instant message within the dialog.

Source

pub async fn handle(&mut self, tx: &mut Transaction) -> Result<()>

Handle incoming transaction for this dialog

Processes incoming SIP requests that are routed to this dialog. This method handles sequence number validation and dispatches to appropriate handlers based on the request method.

§Parameters
  • tx - The incoming transaction to handle
§Returns
  • Ok(()) - Request handled successfully
  • Err(Error) - Failed to handle request
§Supported Methods
  • BYE - Terminates the dialog
  • INFO - Handles information exchange
  • OPTIONS - Handles capability queries
  • UPDATE - Handles session updates
  • INVITE - Handles re-INVITE (when confirmed)
Source

pub async fn process_invite( &self, tx: &mut Transaction, ) -> Result<(DialogId, Option<Response>)>

Trait Implementations§

Source§

impl Clone for ClientInviteDialog

Source§

fn clone(&self) -> ClientInviteDialog

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,