pub struct SipManager { /* private fields */ }
Expand description
Represents an SIP session. SipManager is used to instantiate the SIP connection make / receive calls.
Calling start connects to the SIP Server and starts listening and handling SIP messages.
§Examples
use std::net::SocketAddr;
use std::str::FromStr;
use simple_sip_rs::config::Config;
use simple_sip_rs::manager::SipManager;
async fn start_sip() {
let config = Config {
server_addr: SocketAddr::from_str("192.168.1.100:5060").unwrap(),
own_addr: SocketAddr::from_str("192.168.1.2").unwrap(),
username: "username".to_string(),
password: "password".to_string(),
rtp_port_start: 20480,
rtp_port_end: 20490,
};
let mut sip_manager = SipManager::from_config(config).await.unwrap();
sip_manager.start().await.unwrap();
let outgoing_call = sip_manager.call("1000".to_string());
}
Implementations§
Source§impl SipManager
impl SipManager
Sourcepub async fn from_config(config: Config) -> Result<Self>
pub async fn from_config(config: Config) -> Result<Self>
Create SipManager from the config
Sourcepub async fn start(&mut self) -> Result<()>
pub async fn start(&mut self) -> Result<()>
Starts the registration on the SIP server and starts listening to SIP messages. This function is non-blocking
§Errors
This function will return an error in the following cases:
- Failed to establish the underlying TCP connection
- Failed to authenticate
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stops the underlying SIP socket. This effectively disconnects you from the server.
Sourcepub async fn is_running(&self) -> bool
pub async fn is_running(&self) -> bool
Checks if the connection is alive.
Sourcepub fn take_incoming_call_receiver(&mut self) -> Option<IncomingCallReceiver>
pub fn take_incoming_call_receiver(&mut self) -> Option<IncomingCallReceiver>
Takes the incoming call receiver. This is useful if you want to handle incoming calls in another task / thread.
Will return None if the receiver was already taken.
Sourcepub fn give_incoming_call_receiver(&mut self, receiver: IncomingCallReceiver)
pub fn give_incoming_call_receiver(&mut self, receiver: IncomingCallReceiver)
Give back the incoming call receiver.
Sourcepub async fn recv_incoming_call(&mut self) -> Result<Option<IncomingCall>>
pub async fn recv_incoming_call(&mut self) -> Result<Option<IncomingCall>>
Auto Trait Implementations§
impl Freeze for SipManager
impl !RefUnwindSafe for SipManager
impl Send for SipManager
impl Sync for SipManager
impl Unpin for SipManager
impl !UnwindSafe for SipManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more