FreeSWITCH及VOIP,Openser,电话机器人等产品中文技术资讯、交流、沟通、培训、咨询、服务一体化网络。QQ群:293697898
mod_nwayacd模块详解
这些年排队机经历过好多个版本,此版本为架构的变化。
2014年时使用c++ esl outbound.
2015年golang esl outbound .
2017年golnag esl inbound
2018年c语言mod_nwayacd.
当前为mod_nwayacd,已用于各式各样的呼叫中心场景中,不论外呼还是呼入均可用。但由于之前是需要使用宁卫的cti做对接才可以,所以现在我们升级下,可以脱离宁卫fsgui/cti实现相关的能力。当然需要安装postgresql 12.7及以上的版本,建议不要使用yum,而是自己手工编译postgresql.然后需要把nwaycc.sql导入,余下那么就可以按以下方式对接啦。
```xml
<param name="recover-seconds" value="300"/>
<!--从记录态恢复到空闲态时间长度,默认 300秒5分钟-->
<param name="recover-auto" value="true"/>
<!--自动由模块切换记录态到空闲态-->
<param name="noanswer-to-ready" value="true"/>
<!-- 呼转不应答是否自动转为空闲态,默认为一定要座席手工-->
<param name="typing-auto" value="false"/>
<!--自动将接听的座席状态切换为记录态-->
<param name="auto-answer" value="true"/>
<!--要求座席侧由系统送过来即自动应答,sip_auto_answer及对ip话机的-->
<param name="video-codecs" value="PCMA,H264"/>
<!--送给座席的编码,含语音编码,配置是不是视频客服在数据库中use_video字段-->
<param name="debug" value="true"/>
<param name="asr-str" value="dsr $1 ab"/>
<!--当座席接通时,要调用的识别的字符串,相当于 execute_on_answer=dsr $1 ab
ab则代表是ab两路,还可以a 或b-->
<param name="use-asr" value="false"/>
<!--当座席接通时,是否要使用asr进行识别,true为识别,false为不识别-->
<param name="local-ip" value="10.0.0.21"/>
<!--定义每台服务器的ip,用于排队中 -->
<param name="output_sql" value="true"/>
<!--定义每台服务器的ip,用于排队中 -->
```
```apl 2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1371 dbstring [user=postgres dbname=nwaycc password=Nway2017 host=127.0.0.1 port=5432 sslmode=disable]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1379 jn-prefix [/home/voices/prefix.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1387 jn-suffix [/home/voices/suffix.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1395 jn-0 [/home/voices/0.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1403 jn-1 [/home/voices/1.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1411 jn-2 [/home/voices/2.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1419 jn-3 [/home/voices/3.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1427 jn-4 [/home/voices/4.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1435 jn-6 [/home/voices/5.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1443 jn-6 [/home/voices/6.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1451 jn-7 [/home/voices/7.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1459 jn-8 [/home/voices/8.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1467 jn-9 [/home/voices/9.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1475 default-blacklistwav [/home/blacklist.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1483 default-agent-busy [/home/busy.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1491 default-agent-transfer [/home/bridging.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1498 default-agent-welcome [/home/welcome.wav]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1506 recover-seconds [300]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1512 recover-auto [true]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1519 noanswer-to-ready [true]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1533 auto-answer [true]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1541 video-codecs [PCMA,H264]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1547 debug [true]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1563 asr-str [dsr $1 ab]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1577 local-ip [10.0.0.21]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:1583 output sql string [true]
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:2830 license file:/etc/nway/acd_license.txt
2021-06-30 10:50:16.581741 [DEBUG] mod_nwayacd.c:2831 log file path:/opt/fsgui/mod_log
2021-06-30 10:50:16.581741 [NOTICE] mod_nwayacd.c:2846 授权通道数:200
2021-06-30 10:50:16.601729 [DEBUG] mod_nwayacd.c:242 setting database socket send & recv option 5 seconds
2021-06-30 10:50:16.601729 [DEBUG] mod_nwayacd.c:2910 module nway acd loaded
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:269 Adding Application 'nwayacd'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:269 Adding Application 'nway_bridge'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:269 Adding Application 'nwaycallout'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nwayacd'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_login'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_logout'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_busy'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_ready'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_list_exts'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_add_ext'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_rm_ext'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_set_reged_ext'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_set_unreg_ext'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_set_ext_jobnumber'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_add_group'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_list_groups'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_rm_group'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_set_ring_group'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nwayacd_version'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nwayacd_transfer'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_uuid_hold'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_threeway'
2021-06-30 10:50:16.601729 [NOTICE] switch_loadable_module.c:315 Adding API Function 'nway_uuid_unhold'
```
此为排队机的核心应用,调用方式为:nwayacd 110,后边110为组名称,如果在dialplan文件中配置,则配为如下:
xml
<action application="nwayacd" data="110"/>
在排队过程中以及座席相关的事件等为以下,附1为nwayacd的相关代码,可作为参考:
当有呼入时,会推送一个入队的消息,也就是说,不管有无空闲座席都会先进队列
////////push_queue_event(nway_acd->caller_id_number,nway_acd->group_name,"",uuid,QUEUE_ADD);
Event-Subclass: nwayacd%3A%3Aqueue
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A48%3A21
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A48%3A21%20GMT
Event-Date-Timestamp: 1625046501361727
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_queue_event
Event-Calling-Line-Number: 857
Event-Sequence: 83635064
nway_queue_caller: 13951410223
nway_queue_uuid: 4e12646e-d988-11eb-beed-fdc7c1737958
nway_queue_group: 120
nway_queue_operate: nway_queue_add
nway_status_time: 1625046501
当在主叫挂机时,不论是不是被座席接听过去会发一个出队的消息,如果有空闲座席会多送一次,因为送给座席了后会推一个从队列中remove的消息
```c //////push_queue_event(nway_acd->caller_id_number,nway_acd->group_name,"",uuid,QUEUE_RM);
```
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A48%3A23
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A48%3A23%20GMT
Event-Date-Timestamp: 1625046503261742
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_queue_event
Event-Calling-Line-Number: 857
Event-Sequence: 83635257
nway_queue_caller: 13999566057
nway_queue_uuid: 4b6d172c-d988-11eb-be85-fdc7c1737958
nway_queue_group: 120
nway_queue_operate: nway_queue_remove
nway_status_time: 1625046503
在检测空闲座席时,如果是未接听手动转给其它座席,则会推送
```c //push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,TRANSFERED,nway_acd->transfer_times);
```
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A48
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A48%20GMT
Event-Date-Timestamp: 1625045448521793
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511267
nway_callin: 13963159646
nway_callout: 1002
nway_group: 120
nway_callstatus: transfered
nway_caller_uuid: da41f718-d985-11eb-a64f-fdc7c1737958
nway_queue_time: 1625045448
nway_transfer_times: 1
当有空闲座席时,要呼叫空闲座席时,会推送
```c ///push_queue_event(nway_acd->caller_id_number,nway_acd->group_name,ext,uuid,QUEUE_RM);
```
Event-Subclass: nwayacd%3A%3Aqueue
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A48%3A23
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A48%3A23%20GMT
Event-Date-Timestamp: 1625046503261742
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_queue_event
Event-Calling-Line-Number: 857
Event-Sequence: 83635257
nway_queue_caller: 13999566057
nway_queue_uuid: 4b6d172c-d988-11eb-be85-fdc7c1737958
nway_queue_group: 120
nway_queue_operate: nway_queue_remove
nway_status_time: 1625046503
接着会推送
c
//push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,CALLOUT,nway_acd->transfer_times);
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A48
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A48%20GMT
Event-Date-Timestamp: 1625045448521793
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511267
nway_callin: 13963159646
nway_callout: 1002
nway_group: 120
nway_callstatus: callout
nway_caller_uuid: da41f718-d985-11eb-a64f-fdc7c1737958
nway_queue_time: 1625045448
nway_transfer_times: 1
当呼叫呼不通时,如果是主叫挂
//push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,CALLIN_HANGUP,1);
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A54
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A54%20GMT
Event-Date-Timestamp: 1625045454741733
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511997
nway_callin: 13920502669
nway_callout: 1003
nway_group: 120
nway_callstatus: callin_hangup
nway_caller_uuid: daa9efee-d985-11eb-a667-fdc7c1737958
nway_queue_time: 1625045454
nway_transfer_times: 1
被 叫挂
c
//push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,NOANSWER,nway_acd->transfer_times);
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A54
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A54%20GMT
Event-Date-Timestamp: 1625045454741733
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511997
nway_callin: 13920502669
nway_callout: 1003
nway_group: 120
nway_callstatus: noanswer
nway_caller_uuid: daa9efee-d985-11eb-a667-fdc7c1737958
nway_queue_time: 1625045454
nway_transfer_times: 1
同时再次将来电加入到队列中,等待主处理线程再次处理
c
//push_queue_event(nway_acd->caller_id_number,nway_acd->group_name,"",nway_acd->uuid,QUEUE_ADD); Event-Subclass: nwayacd%3A%3AqueueEvent-Name: CUSTOMCore-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958FreeSWITCH-Hostname: lihao.nwayFreeSWITCH-Switchname: lihao.nwayFreeSWITCH-IPv4: 10.0.0.21FreeSWITCH-IPv6: %3A%3A1Event-Date-Local: 2021-06-30%2017%3A48%3A23Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A48%3A23%20GMTEvent-Date-Timestamp: 1625046503401729Event-Calling-File: mod_nwayacd.cEvent-Calling-Function: push_queue_eventEvent-Calling-Line-Number: 857Event-Sequence: 83635308nway_queue_caller: 13954161425nway_queue_uuid: 4f4b9a62-d988-11eb-bf11-fdc7c1737958nway_queue_group: 120nway_queue_operate: nway_queue_addnway_status_time: 1625046503
在这里会按配置的分机报不报工号而决定报工号的事,同时推消息
//push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,ANSWERED,nway_acd->transfer_times);
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A48
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A48%20GMT
Event-Date-Timestamp: 1625045448901798
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511306
nway_callin: 13963159646
nway_callout: 1002
nway_group: 120
nway_callstatus: answered
nway_caller_uuid: da41f718-d985-11eb-a64f-fdc7c1737958
nway_queue_time: 1625045448
nway_transfer_times: 1
座席挂机时
//push_event(nway_acd->uuid,nway_acd->caller_id_number,nway_acd->group_name,nway_acd->agent_number,HANGUP,nway_acd->transfer_times);
Event-Subclass: nwayacd%3A%3Ainfo
Event-Name: CUSTOM
Core-UUID: 69bba2f6-d2f9-11eb-9937-fdc7c1737958
FreeSWITCH-Hostname: lihao.nway
FreeSWITCH-Switchname: lihao.nway
FreeSWITCH-IPv4: 10.0.0.21
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2021-06-30%2017%3A30%3A54
Event-Date-GMT: Wed,%2030%20Jun%202021%2009%3A30%3A54%20GMT
Event-Date-Timestamp: 1625045454501765
Event-Calling-File: mod_nwayacd.c
Event-Calling-Function: push_event
Event-Calling-Line-Number: 827
Event-Sequence: 83511835
nway_callin: 13915987797
nway_callout: 1003
nway_group: 120
nway_callstatus: hangup
nway_caller_uuid: da0df95e-d985-11eb-a649-fdc7c1737958
nway_queue_time: 1625045454
nway_transfer_times: 1
自动将当前的channel和某个uuid的channel进行桥接
xml
<action application="nway_bridge" data="uuid"/>
通过这个app将进行外呼简单化
nwaycallout
xml
<extension name="nwaycallout"> <condition field="destination_number" expression="^(.*)$"> <action application="nwaycallout" data="$0 test $0"/> </condition></extension>
nwayacd uuid group_number
在fs_cli中
nwayacd c6571e56-498e-458b-bb8d-d56867b48253 110
如果是通过esl连接,则需要按如下调用
bgapi nwayacd c6571e56-498e-458b-bb8d-d56867b48253 110
通过esl添加一个组
nway_add_group group mode
bgapi nway_add_group 110 4
mode说明:
0,sequence;
1,random;
2,crycle;
3,remember+0;
4,remember+1;
5,remember+2;
配置这个座席组特有的一些铃声
nway_set_ring_group group welcome_ring blacklist_ring busy_ring transfer_ring
bgapi nway_set_ring_group 110 /nway/welcome.wav /nway/black.wav /nway/busy.wav /nway/transfer.wav
删除某一个组
nway_rm_group group_number
bgapi nway_rm_group 110
输出当前nwayacd的版本
列出所有的分机及状态,建议座席不忙时用
通过esl添加一个分机帐号
nway_add_ext extension password
nway_add_ext 2003 1234
通过esl为某分机设定个工号,可以按默认配置文件 播放工号
nway_set_ext_jobnumber extension jobnumber use
nway_set_ext_jobnumber 1000 1234 true
将某个分机置为已注册
nway_set_reged_ext 2003
将某个分机置为未注册
nway_set_unreg_ext 2003
通过esl删除一个存于数据库的分机
nway_rm_ext 2003
在排队时,如果当前座席顾不上处理该来电,则通过此接口
nwayacd_transfer [uuid] [extension]
nwayacd_transfer c6571e56-498e-458b-bb8d-d56867b48253 1002
将某个座席号码加入到多个组中,相当于登录或迁入或上线
nway_login extension group_list
nway_login 1000 120,119,110
将某个座席离席或下线或迁出
nway_logout extension
nway_logout 1000
将座席置忙
nway_busy extension
nway_busy 1000
将座席置闲
nway_ready extension
nway_ready 1000
hold主叫,但座席能听到座席的声音
nway_uuid_hold uuid
unhold主叫,让座席和来电正常通话
nway_uuid_unhold uuid
三方通话
nway_threeway [uuid] phone gateway
nway_uuid_hold uuid 018621575908 gw1
先用 psql -U postgres -h 目录ip 登录到对应的postgresql上,然后创建数据库
#create database nwaycc;
#\q #退出pg 执行以下的命令
psql -U postgres -W -d nwaycc -f nwayccxxx.sql -h 目标ip
手工编译参考附2
将宁卫的freeswitchxxx.rpm或freeswitchxxx.tar.gz进行rpm -hiv freeswitch.rpm或tar zxvf freeswitchxxx.tar.gz /usr/local
cp nwayacd.so /usr/local/freeswitch/mod/. && cp libnway_auth_lib.so /usr/local/freeswitch/lib/. && cp nwayacd.conf.xml /usr/local/freeswitch/conf/autoload_configs/. 修改这里的数据库连接部分即可,然后运行 fs_cli -x "reload mod_nwayacd"
仅作为参考,如果不懂c/c++可以跳过这段代码
c
//event field name#define AGENT_INFO "nwayacd::info" #define CALLIN "callin"#define AGENT_CALLIN "nway_callin"#define AGENT_CALLOUT "nway_callout"#define AGENT_GROUP "nway_group"#define AGENT_STATUS "nway_callstatus"#define NWAY_TIME "nway_status_time"#define NWAY_UUID "nway_caller_uuid"//event status#define CALLOUT "callout" //呼出#define ANSWERED "answered"#define NOANSWER "noanswer"#define HANGUP "hangup"#define CALLIN_HANGUP "callin_hangup"#define TRANSFERED "transfered"// queue#define QUEUE_INFO "nwayacd::queue"#define QUEUE_ADD "nway_queue_add"#define QUEUE_RM "nway_queue_remove"#define QUEUE_OPERATE "nway_queue_operate"#define QUEUE_CALLER "nway_queue_caller"#define QUEUE_UUID "nway_queue_uuid"#define QUEUE_EXTENSION "nway_queue_extension"#define QUEUE_TIME "nway_queue_time"#define QUEUE_GROUP "nway_queue_group"//channel variable define#define VAR_NWAY_ACD "nway_acd"#define VAR_CALLOUT_EXTENSION "nway_called_extension"//agent status#define AGENT_OPT_INFO "nwayacd::agent"#define AGENT_OPT_LOGIN "nway_agent_login"#define AGENT_OPT_LOGOUT "nway_agent_logout"#define AGENT_OPT_BUSY "nway_agent_busy"#define AGENT_OPT_READY "nway_agent_ready"#define AGENT_OPT_EXT "nway_agent_extension"#define AGENT_OPT_STATUS "nway_agent_status"#define NWAY_TRANSFER "nway_transfer_ext"
推送消息函数如下,仅作为参考,如果不懂c/c++可以跳过这段代码:
c
static void push_event(const char* uuid,const char* caller,const char* group_number,const char* extension,const char* status,int times){ switch_event_t *event; if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AGENT_INFO) == SWITCH_STATUS_SUCCESS) { switch_time_t nway_time = switch_micro_time_now() / 1000000; switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_CALLIN, caller); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_CALLOUT, extension); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_GROUP, group_number); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_STATUS,status); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, NWAY_UUID,uuid); switch_event_add_header(event, SWITCH_STACK_BOTTOM, QUEUE_TIME, "%" SWITCH_TIME_T_FMT, nway_time); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nway_transfer_times", "%d", times); switch_event_fire(&event); }}//座席上线、下线、置忙、置闲、通话中、空闲等事件static void push_agent_event(const char* extension,const char* status){ switch_event_t *event; if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AGENT_OPT_INFO) == SWITCH_STATUS_SUCCESS) { switch_time_t nway_time = switch_micro_time_now() / 1000000; switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_OPT_EXT, extension); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, AGENT_OPT_STATUS,status); switch_event_add_header(event, SWITCH_STACK_BOTTOM, QUEUE_TIME, "%" SWITCH_TIME_T_FMT, nway_time); switch_event_fire(&event); }}static void push_queue_event(const char* caller,const char* group_number,const char* extension,const char* uuid,const char* status){ switch_event_t *event; if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, QUEUE_INFO) == SWITCH_STATUS_SUCCESS) { switch_time_t nway_time = switch_micro_time_now() / 1000000; switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, QUEUE_CALLER, caller); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, QUEUE_EXTENSION, extension); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, QUEUE_UUID, uuid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, QUEUE_GROUP, group_number); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, QUEUE_OPERATE,status); switch_event_add_header(event, SWITCH_STACK_BOTTOM, NWAY_TIME, "%" SWITCH_TIME_T_FMT, nway_time); switch_event_fire(&event); }}
CentOS 6.3 Minimal 源码安装 PostgreSQL 9.2.3
环境:CentOS 6.3 最小化缺省安装,配置好网卡。
安装PostgreSQL前,确认Internet连接正常,以便下载安装文件。
先使用 yum -y update 指令升级系统到最新版本。
本安装将PostgreSQL的数据文件与执行文件分离,如果你打算设置到不同的路径,注意修改对应的执行命令和数据库初始化脚本。
# 修改防火墙设置,打开5432端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
# 重启防火墙使新设置生效 service iptables restart
# 新增用户组 groupadd postgres
# 新增用户 useradd postgres -g postgres
# 新建数据库执行文件目录 mkdir -p /usr/local/pgsql
# 新建数据库数据文件目录 mkdir -p /db/pgsql/data
# 修改目录拥有者 chown -R postgres /usr/local/pgsql/.
chown -R postgres /db/pgsql/data/
# 编辑PATH搜索路径 vi /etc/profile Append these 2 lines to the end of the file: PATH=/usr/local/pgsql/bin:$PATH export PATH
# 生效PATH搜索路径 source /etc/profile
# 安装编译源码所需的工具和库 yum -y install wget gcc readline-devel zlib-devel make
debian apt-get install zlibc libghc-zlib-dev libzlcore-dev gcc make git automake libreadline-dev
# 进入源码压缩包下载目录 cd /usr/src
# 下载源码压缩包 wget https://ftp.postgresql.org/pub/source/v12.7/postgresql-12.7.tar.gz
# 解压缩源码包 tar zxvf ./postgresql-12.7.tar.gz
# 进入解压缩源码目录 cd ./postgresql-12.7
# 执行源码编译配置脚本 ./configure
# 编译源码 make
# 安装 make install
# 变更登录用户 su - postgres
# 执行数据库初始化脚本 /usr/local/pgsql/bin/initdb --encoding=utf8 -D /db/pgsql/data
# 退出变更登录 exit
# 复制PostgreSQL执行脚本
cp /usr/src/postgresql-12.7/contrib/start-scripts/linux /etc/init.d/postgresql
# 增加执行权限 chmod +x /etc/init.d/postgresql
# 编辑PostgreSQL执行脚本,指定数据库文件目录 vi /etc/init.d/postgresql PGDATA="/db/pgsql/data"
# 编辑配置文件,配置可访问数据库的网络地址 (注意别忘了去掉#listen_addresses=前面的#)
vi /db/pgsql/data/postgresql.conf listen_addresses = '*'
# 启动PostgreSQL服务 service postgresql start
# 以postgres用户登录数据库,修改postgres用户的数据库密码 psql -U postgres postgres=# ALTER USER postgres PASSWORD 'Nway2017'; postgres=# \q
exit
# 编辑配置文件,设置密码md5验证 vi /db/pgsql/data/pg_hba.conf
"local" is for Unix domain socket connections only
local all all md5
IPv4 local connections:
host all all 0.0.0.0/0 md5
# 重启数据库服务 service postgresql restart
设置开机自动启动服务
chkconfig postgresql on
vi /etc/profile
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib export LD_LIBRARY_PATH
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/pgsql/include export C_INCLUDE_PATH
source /etc/profile