我正在尝试将FreesSWITCH与Mizu WebRTC to SIP client一起使用。 如果被叫用户注册到FreesSWITCH,则呼叫应该路由到用户。否则,呼叫应路由到出站SIP服务器。
问题是我无法从FreesSWITCH拨号方案中找出用户当前是否已注册。我在默认的拨号方案中有以下内容:
<!-- If the user doesn't exist, forward to outbound SIP -->
<extension name="check_user">
<condition field="${user_exists(id ${destination_number} $${domain})}" expression="false">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
<!-- If the user is registered, forward the call to them -->
<extension name="check_user_registered">
<condition field="${sofia_contact(profile/${destination_number}@$${domain})}" expression="(.+)">
<action application="bridge" data="$1" />
</condition>
</extension>
<!-- Otherwise forward to outbound SIP -->
<extension name="outbound">
<condition field="destination_number" expression="^.*$">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
然而&#34; check_user_registered&#34;即使用户实际上没有从Webphone注册,似乎也会传递规则,因此FreesSWITCH将把呼叫发送给用户,但后来发现它没有注册并且呼叫失败。 (我认为WebRTC在这里并不重要,这对SIP到SIP的呼叫也是一样的。)这是相关的日志:
Dialplan: sofia/internal/2233@81.12.74.77 Regex (PASS) [check_user_registered] ${sofia_contact(profile/${destination_number}@rtc.mizu-voip.com)}(error/user_not_registered) =~ /(.+)/ break=on-false
Dialplan: sofia/internal/2233@81.12.74.77 Action bridge(error/user_not_registered)
Freeswitch hangup with 480 Temporarily Unavailable / USER_NOT_REGISTERED
您是否知道从FreesSWITCH拨号方案查询用户注册状态的任何可靠方法?
答案 0 :(得分:1)
sofia_contact
将返回字符串error/user_not_registered
。在您的情况下,您将根据.+
正则表达式检查返回的值。当然错误字符串也会匹配。
您需要一个与^error
匹配的条件,然后定义动作和反动作。
答案 1 :(得分:1)
使用sofia_contact
了解被叫人是否已注册。
例如:
sofia_contact 1001
将此归还给我
索菲亚/内部/ SIP:1001 @ myip_address:52573; rinstance = a1b0a9cfddc6a8c3;运输= TCP
sofia_contact 1002
误差/ user_not_registered
另一种选择是将注册用户存储到数据库中并使用odbc查询获取结果并进行比较。(这将是一个绝妙的主意)