# freeswitch-client **Repository Path**: i_bobo/freeswitch-client ## Basic Information - **Project Name**: freeswitch-client - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-02 - **Last Updated**: 2025-08-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FreeSWITCH Rust 客户端 这是一个用Rust编写的FreeSWITCH客户端,支持通过ESL (Event Socket Library) 与FreeSWITCH服务器通信,实现拨打电话、监听事件等功能。 ## 功能特性 - 🔌 连接到FreeSWITCH ESL接口 - 📞 发起电话呼叫 - 📡 实时监听FreeSWITCH事件 - 📋 列出活动通道 - 📊 获取FreeSWITCH状态 - 🔐 支持ESL认证 ## 系统要求 - Rust 1.70+ - FreeSWITCH 1.10+ - Windows 10/11 (当前系统) ## 安装和构建 1. 克隆项目: ```bash git clone cd freeswitch-client ``` 2. 构建项目: ```bash cargo build --release ``` ## 使用方法 ### 基本语法 ```bash # Windows PowerShell .\target\release\freeswitch-client.exe [OPTIONS] ``` ### 命令行选项 - `-h, --host ` - FreeSWITCH服务器地址 (默认: 127.0.0.1) - `-p, --port ` - FreeSWITCH ESL端口 (默认: 8021) - `-w, --password ` - ESL认证密码 (默认: ClueCon) ### 可用命令 #### 1. 拨打电话 ```bash # 基本拨号 .\target\release\freeswitch-client.exe call -n 1234567890 # 自定义超时和监听时间 .\target\release\freeswitch-client.exe call -n 1234567890 -t 45 -l 120 ``` 参数说明: - `-n, --number ` - 要拨打的电话号码 (必需) - `-t, --timeout ` - 呼叫超时时间,秒 (默认: 30) - `-l, --listen-duration ` - 监听事件时间,秒 (默认: 60) #### 2. 列出活动通道 ```bash .\target\release\freeswitch-client.exe list-channels ``` #### 3. 获取FreeSWITCH状态 ```bash .\target\release\freeswitch-client.exe status ``` #### 4. 监听事件 ```bash # 监听60秒事件 .\target\release\freeswitch-client.exe listen # 监听指定时间 .\target\release\freeswitch-client.exe listen -d 300 ``` 参数说明: - `-d, --duration ` - 监听时间,秒 (默认: 60) ### 完整示例 ```bash # 连接到远程FreeSWITCH服务器并拨打电话 .\target\release\freeswitch-client.exe -h 192.168.1.100 -p 8021 -w MyPassword call -n 1234567890 # 监听事件5分钟 .\target\release\freeswitch-client.exe -h 192.168.1.100 listen -d 300 # 查看当前活动通道 .\target\release\freeswitch-client.exe list-channels ``` ## FreeSWITCH配置 确保您的FreeSWITCH服务器已正确配置ESL: 1. 在 `autoload_configs/event_socket.conf.xml` 中启用ESL: ```xml ``` 2. 重启FreeSWITCH服务: ```bash # Windows net stop freeswitch net start freeswitch ``` ## 事件说明 客户端会监听以下FreeSWITCH事件: - `CHANNEL_CREATE` - 通道创建 - `CHANNEL_ANSWER` - 通话接通 - `CHANNEL_HANGUP` - 通话挂断 - `CHANNEL_DESTROY` - 通道销毁 - `BACKGROUND_JOB` - 后台任务完成 ## 故障排除 ### 常见问题 1. **连接失败** - 检查FreeSWITCH服务器是否运行 - 确认ESL端口(8021)是否开放 - 验证防火墙设置 2. **认证失败** - 确认ESL密码是否正确 - 检查FreeSWITCH配置文件中的密码设置 3. **呼叫失败** - 确认FreeSWITCH中有配置好的用户(如user/1000) - 检查拨号计划配置 - 验证目标号码格式 ### 调试模式 启用详细日志: ```bash # 设置环境变量 $env:RUST_LOG="debug" .\target\release\freeswitch-client.exe call -n 1234567890 ``` ## 开发 ### 项目结构 ``` src/ ├── main.rs # 主程序入口和命令行处理 ├── esl.rs # ESL连接和消息处理 └── client.rs # FreeSWITCH客户端功能 ``` ### 添加新功能 1. 在 `client.rs` 中添加新的方法 2. 在 `main.rs` 中添加对应的命令 3. 更新文档 ## 许可证 MIT License ## 贡献 欢迎提交Issue和Pull Request!