Asterisk的Chan_SIP和PJSIP支持SIP Instant Message功能,配合SIP软电话,类似于QQ即时通信功能。
参考网址:
https://asteriskfaqs.org/2015/11/16/asterisk-users/how-do-i-enable-instant-messaging-support-for-pjsip-endpoints-on-asterisk-1310.html
一、Chan_SIP下IM配置
1、sip.conf配置文件
/etc/asterisk/sip.conf文件
[general]
accept_outofcall_message = yes
outofcall_message_context = astsms
auth_message_requests = no
2、extensions.conf
/etc/asterisk/extensions.conf文件
[send_message]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
exten => _.,n,Hangup()
;
; Handle failed messaging
exten => _.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _.,n,Hangup()
二、PJSIP下IM配置
1、pjsip.endpoint.conf文件
在每个分机后面都添加message_context=send_message,以FreePBX-1805-2和Yeastar的IPPBX为例,创建一个101分机
pjsip.endpoint.conf配置文件
[101]
type=endpoint
aors=101
auth=101-auth
allow=ulaw,alaw,gsm,g726,g722
context=from-internal
callerid=101 <101>
dtmf_mode=rfc4733
mailboxes=101@device
mwi_subscribe_replaces_unsolicited=yes
transport=0.0.0.0-udp
aggregate_mwi=yes
named_call_group=yes
named_pickup_group=yes
rtcp_mux=yes
bundle=no
ice_support=no
media_use_received_transport=no
media_encryption=no
timers=yes
media_encryption_optimistic=no
rtp_symmetric=yes
rewrite_contact=yes
force_rport=yes
language=en
message_context=send_message
2、extensions_custom.conf文件增加send_message的context
extensions_custom.conf文件
[send_message]
exten => _.,1,NoOp([${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}] SMS receiving dialplan invoked)
exten => _.,n,NoOp(Message To: ${MESSAGE(to)})
exten => _.,n,NoOp(Message From: ${MESSAGE(from)})
exten => _.,n,NoOp(Message Body: ${MESSAGE(body)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,Set(ACTUALTO_TECH=${CUT(ACTUALTO,:,1)})
exten => _.,n,Set(ACTUALTO_SUF=${IF($[${LEN(${CUT(ACTUALTO,:,3)})}>0]?${CUT(ACTUALTO,:,3)}:${CUT(ACTUALTO,:,2)})})
exten => _.,n,Set(ACTUALTO=${ACTUALTO_TECH}:${ACTUALTO_SUF})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Message Send status : ${MESSAGE_SEND_STATUS})
exten => _.,n,Hangup()
三、软电话测试
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/476.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~