Crates.io | freeswitch-esl-rs |
lib.rs | freeswitch-esl-rs |
version | 0.3.1 |
source | src |
created_at | 2022-10-15 20:36:00.261562 |
updated_at | 2023-03-28 01:53:09.840299 |
description | Freeswitch ESL |
homepage | http://chiselapp.com/user/bit4bit/repository/freeswitch-esl-rs/index |
repository | http://chiselapp.com/user/bit4bit/repository/freeswitch-esl-rs/index |
max_upload_size | |
id | 689132 |
size | 29,538 |
caution: not thread safe
extern crate freeswitch_esl_rs;
use std::net::{TcpStream};
use std::env;
use freeswitch_esl_rs::{Connection,Client,Event};
fn main() -> std::io::Result<()> {
let args: Vec<String> = env::args().collect();
let host = &args[1];
let event = &args[2];
// open stream
let mut stream = TcpStream::connect(host)?;
// open connection
let conn = Connection::new(&mut stream);
// create freeswitch esl client
let mut client = Client::new(conn);
// authenticate to freeswitch
client.auth("cloudpbx").expect("fails to authenticate");
// enable events
client.event(event).expect("fails enabling events");
loop {
// poll event
let event: Event = client.pull_event().unwrap();
println!("{:?}", event);
}
Ok(())
}