A:
nc -l -k 192.168.0.100 8040
B:
nc 192.168.0.100 8040
外连就是freeswitch代替B
内连就是freeswitch代替A
外连
dialplan/default.xml
watch -n 1 'netstat -an|grep 8040'
监控nc端口
用客户端拨打1237
看端口变成 ESTABLISHED
去终端A 输入
connect 回车两下
Event-Name: CHANNEL_DATA Core-UUID: c6699b05-fb5b-4feb-ae89-1d302ae28b21 FreeSWITCH-Hostname: bogon FreeSWITCH-Switchname: bogon FreeSWITCH-IPv4: 192.168.0.100 FreeSWITCH-IPv6: 2408%3A84e1%3A41%3A926d%3Af0f6%3A8a6f%3Ac0d%3A699c Event-Date-Local: 2019-05-31%2011%3A22%3A50 Event-Date-GMT: Fri,%2031%20May%202019%2003%3A22%3A50%20GMT Event-Date-Timestamp: 1559272970377169 Event-Calling-File: mod_event_socket.c Event-Calling-Function: parse_command Event-Calling-Line-Number: 2011 Event-Sequence: 829 Channel-Direction: inbound Channel-Logical-Direction: inbound Channel-Username: 1006 Channel-Dialplan: XML Channel-Caller-ID-Name: 1006 Channel-Caller-ID-Number: 1006 Channel-Orig-Caller-ID-Name: 1006 Channel-Orig-Caller-ID-Number: 1006 Channel-Network-Addr: 192.168.0.101 Channel-ANI: 1006 Channel-Destination-Number: 1237
输入命令播放声音
sendmsg call-command: execute execute-app-name: playback execute-app-arg: local_stream://moh 两下回车
返回
Content-Type: command/reply Reply-Text: +OK
客户端开始播放声音
############
内连
配置 默认有
在 autoload_configs/event_socket.conf.xml里面
打开注释apply-inbound-acl ,value改成成lan
和修改ip
不改会报错:[WARNING] mod_event_socket.c:2641 IP 172.18.1.112 Rejected by acl "loopback.auto"
端口为8021
所以用
#nc 192.168.0.100 8021
nc localhost 8021
auth ClueCon 两下回车
源码里的testclient.c
freeswitch/libs/esl/下的
#include#include #include int main(void) { esl_handle_t handle = {{0}}; esl_connect(&handle, "192.168.0.100", 8021, NULL, "ClueCon"); esl_send_recv(&handle, "api status\n\n"); if (handle.last_sr_event && handle.last_sr_event->body) { printf("%s\n", handle.last_sr_event->body); } else { // this is unlikely to happen with api or bgapi (which is hardcoded above) but prefix but may be true for other commands printf("%s\n", handle.last_sr_reply); } esl_disconnect(&handle); return 0; }
#########
/opt/meituan/sip/freeswitch/libs/esl# make
生成.lib/libesl.a
FSDG-code/chapter19/myesl$ make
######
open -a /Applications/Google\ Chrome.app
open "http://www.baidu.com"