Dialplan里的配置
可以为freeswitch配置一个或若干个号码,当其他的sip终端通过拨打此号码时,通过拨号路由,查找到此号码,从而执行lua脚本。在Dialplan里的配置如下:
<extension name="1200">
<condition field="destination_number" expression="^1200$">
<action application="lua" data="test.lua"/>
</condition>
</extension>
需要说明的是:
dialplan是通过xml寻找拨号规则的,具体流程为:
①sip信令到达,invite消息,抵达sip endpoint的回调机制,例如sofia终端,会到达sip_handle_sip_i_invite函数做相应处理。
②在sofia_handle_sip_i_invite函数中,建立一个新的session,并未session创建一个channel。在channel中,包含一个caller_profile,这是一个类型为switch_caller_profile_t的结构体,记录了当前呼叫的各种必要属性。Caller_profile里记录了当前的route方式为“XML”,这里明确指明了通过xml文件查询拨号规则。(见该函数里的switch_channel_set_caller_profile(channel, tech_pvt->caller_profile)&