Skip to content

Commit

Permalink
adding few more functions from mod dp_tools (#3)
Browse files Browse the repository at this point in the history
* few more functions from mod dp_tools
  • Loading branch information
srikarm99 authored Sep 5, 2023
1 parent a39ba4c commit 14dba13
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "freeswitch-esl"
version = "0.1.0-alpha.1"
authors = ["KaranGauswami <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
description = "FreeSwitch ESL implementation for Rust"
Expand Down
33 changes: 33 additions & 0 deletions src/dp_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,39 @@ impl EslConnection {
pub async fn playback(&self, file_path: &str) -> Result<Event, EslError> {
self.execute(PLAYBACK_APP, file_path).await
}

/// record_session during outbound mode
pub async fn record_session(&self, file_path: &str) -> Result<Event, EslError> {
self.execute("record_session", file_path).await
}

/// send dtmf during outbound mode
pub async fn send_dtmf(&self, dtmf_str: &str) -> Result<Event, EslError> {
self.execute("send_dtmf", dtmf_str).await
}

/// wait for silence during outbound mode
pub async fn wait_for_silence(&self, silence_str: &str) -> Result<Event, EslError> {
self.execute("wait_for_silence", silence_str).await
}

/// sleep for specified milliseconds in outbound mode
pub async fn sleep(&self, millis: i128) -> Result<Event, EslError> {
self.execute("sleep", &millis.to_string()).await
}

///set a channel variable
pub async fn set_variable(&self, var: &str, value: &str) -> Result<Event, EslError> {
let args = format!("{}={}", var, value);
self.execute("set", &args).await
}

///add a freeswitch log
pub async fn fs_log(&self, loglevel: &str, msg: &str) -> Result<Event, EslError> {
let args = format!("{} {}", loglevel, msg);
self.execute("log", &args).await
}


#[allow(clippy::too_many_arguments)]
/// Used for mod_play_and_get_digits
Expand Down

0 comments on commit 14dba13

Please sign in to comment.