Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Rust

on:
push:
branches: [main]
branches: "*"
pull_request:
branches: [main]

Expand All @@ -14,6 +14,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Test
run: cargo test --all-features --all-targets --verbose
17 changes: 7 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ repository = "https://github.com/KaranGauswami/freeswitch-esl.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["io-util", "net", "rt"] }
tokio = { version = "1", features = ["io-util", "net", "rt","sync"] }
tracing = "0.1"
bytes = "1.4"
tokio-util = { version = "0.7", features = ["codec"] }
tokio-stream = "0.1"
futures = "0.3"
serde_json = "1.0"
uuid = { version = "1.4", features = ["v4"] }
thiserror = "1.0"
nom = "7.1"
dashmap = "5.5"

[dev-dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
anyhow = "*"
regex ="*"
ntest = "0.9.0"
tokio = { version = "1.32", features = ["rt-multi-thread", "macros"] }
anyhow = "1.0"
regex ="1.9"
ntest = "0.9.0"
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# UNSTABLE BRANCH

# freeswitch-esl (WIP)

![workflow](https://github.com/KaranGauswami/freeswitch-esl/actions/workflows/rust.yml/badge.svg)
Expand All @@ -12,12 +14,14 @@ FreeSwitch ESL implementation for Rust

```rust
use freeswitch_esl::{Esl, EslError};
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), EslError> {
let addr = "localhost:8021"; // Freeswitch host
let password = "ClueCon";
let inbound = Esl::inbound(addr, password).await?;
let stream = TcpStream::connect(addr).await?;
let inbound = Esl::inbound(stream, password).await?;

let reloadxml = inbound.api("reloadxml").await?;
println!("reloadxml response : {:?}", reloadxml);
Expand All @@ -33,6 +37,7 @@ async fn main() -> Result<(), EslError> {
## Outbound Example

```rust
use tokio::net::TcpListener;
use freeswitch_esl::{Esl, EslConnection, EslError};

async fn process_call(conn: EslConnection) -> Result<(), EslError> {
Expand All @@ -49,7 +54,6 @@ async fn process_call(conn: EslConnection) -> Result<(), EslError> {
"conference/conf-bad-pin.wav",
)
.await?;
println!("got digit {}", digit);
conn.playback("ivr/ivr-you_entered.wav").await?;
conn.playback(&format!("digits/{}.wav", digit)).await?;
conn.hangup("NORMAL_CLEARING").await?;
Expand All @@ -58,12 +62,13 @@ async fn process_call(conn: EslConnection) -> Result<(), EslError> {

#[tokio::main]
async fn main() -> Result<(), EslError> {
env_logger::init();
let addr = "0.0.0.0:8085"; // Listening address
let listener = Esl::outbound(addr).await?;
println!("Listening on {}", addr);
let listener = TcpListener::bind(addr).await?;

loop {
let (socket, _) = listener.accept().await?;
let socket = Esl::outbound(socket).await?;
tokio::spawn(async move { process_call(socket).await });
}
}
Expand Down
6 changes: 4 additions & 2 deletions examples/inbound.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use freeswitch_esl::{Esl, EslError};
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), EslError> {
let addr = "localhost:8021"; // Freeswitch host
let addr = "localhost:8022"; // Freeswitch host
let password = "ClueCon";
let inbound = Esl::inbound(addr, password).await?;
let stream = TcpStream::connect(addr).await?;
let inbound = Esl::inbound(stream, password).await?;

let reloadxml = inbound.api("reloadxml").await?;
println!("reloadxml response : {:?}", reloadxml);
Expand Down
7 changes: 5 additions & 2 deletions examples/outbound.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tokio::net::TcpListener;

use freeswitch_esl::{Esl, EslConnection, EslError};

async fn process_call(conn: EslConnection) -> Result<(), EslError> {
Expand All @@ -15,7 +17,7 @@ async fn process_call(conn: EslConnection) -> Result<(), EslError> {
"conference/conf-bad-pin.wav",
)
.await?;
println!("got digit {}", digit);
println!("Received Digit: {}", digit);
conn.playback("ivr/ivr-you_entered.wav").await?;
conn.playback(&format!("digits/{}.wav", digit)).await?;
conn.hangup("NORMAL_CLEARING").await?;
Expand All @@ -26,10 +28,11 @@ async fn process_call(conn: EslConnection) -> Result<(), EslError> {
async fn main() -> Result<(), EslError> {
let addr = "0.0.0.0:8085"; // Listening address
println!("Listening on {}", addr);
let listener = Esl::outbound(addr).await?;
let listener = TcpListener::bind(addr).await?;

loop {
let (socket, _) = listener.accept().await?;
let socket = Esl::outbound(socket).await?;
tokio::spawn(async move { process_call(socket).await });
}
}
19 changes: 0 additions & 19 deletions src/code.rs

This file was deleted.

Loading