freeswitch是一个电话软交换服务,因为项目须要在网页端作一个软电话,特意研究了一下。web
安装frees witch比较简单,在centos下面推荐的方式是docker
yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release yum install -y freeswitch-config-vanilla freeswitch-lang-* freeswitch-sounds-* systemctl enable freeswitch
能够经过它控制f.顺利的话上面三步就完成了安装,对于通常状况确实什么依赖就安装什么依赖,实在不行能够docker 部署它嘛。express
安装完成了使用 netstat -anop|grep freeswitch 是能够看到f占用的端口的。其中5066是websocket端口,网页端能够直接用SIP.js链接,5060是SIP端口,不管软电话仍是实体的IP电话均可以经过5060注册上。默认有1000-1020 这20个用户,默认密码在$conf/var.xml里面是能够设置的,默认密码也是1234。选用一个IP电话,填上IP+端口已经用户密码以后就注册上了f.利用fs_cli是能够看到这些注册的设备的。centos
sofia status profile internal reg
注册两个以后就能够互相拨打测试一下。bash
要想拨打出去的有一个SIP网关,SIP网关通常是运营商提供给你的,也能够是本身的网关,不过也须要在运营商注册。在$conf/sip_profiles/external目录下面有一个example.xml,复制一个出来,而后填上提供的SIP地址已经帐号密码。最后在fs_cli 里面reloadxml就会去注册。websocket
sofia status
光是注册了网关还不够,还得让f知道什么样的号码才须要丢给getway。因此须要在$conf/dialplan/default 里面新建一个xml。若是是要求0开头的就给getway须要这样配置。app
<extension name="call out"> <condition field="destination_number" expression="^0(\d+)$"> <action application="bridge" data="sofia/gateway/om20/$1"/> </condition>
一样须要fs_cli ->reloadxml。如今随便用一个注册在f上的话机加上0拨打本身的手机号都是能够拨通的。若是打不过fs_cli能够看到错误日志的,分析日志而且处理掉dom
如今还打不进来,要想外部能呼入得配置$conf/dialplan/public。若是我须要全部号码呼入都同振,能够这样配置。socket
<condition field="destination_number" expression="^(.*)$"> <action application="set" data="domain_name=$${domain}"/> <!-- This example maps the DID 5551212 to ring 1000 in the default context --> <!-- <action application="transfer" data="1000 XML default"/>--> <!--顺振动--> <!-- <action application="bridge" data="user/1002@${domain_name}|user/1001@${domain_name}"/>--> <!--同振动--> <action application="bridge" data="user/1002@${domain_name},user/1001@${domain_name}"/> <action application="set" data="bridge_early_media=true"/>
好了,如今别人打进来的时候全部注册的话机都会响铃。一个接听了其余的就会自动挂断。学习
我也是刚刚研究freeswitch,说的不对的地方但愿多多指正,互相学习