微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

freeswitch挂断原因处理

未分类 aide_941 2℃ 0评论

因为在挂断的时候,会有一个特殊的env对象产生,所以:

diaplan添加:

<action application=”set” data=”api_hangup_hook=lua hook-test.lua”/>
或者lua添加:
 session:setVariable(“api_hangup_hook”,”lua hook-test.lua”)
然后hook-test.lua:
local dat = env:serialize()            
freeswitch.consoleLog("INFO","Here's everything:\n-----------------" .. dat .. "-------------------\n")

local hangupCause = env:getHeader("originate_disposition")   
local callerIdNumber = env:getHeader("Caller-Caller-ID-Number")
local sip_hangup_disposition = env:getHeader("sip_hangup_disposition")  
local sip_term_status = env:getHeader("sip_term_status")  
local current_application_data = env:getHeader("current_application_data")  

if current_application_data == "Hold.lua" or current_application_data == "HoldStop.lua" then

  if sip_hangup_disposition == "send_bye" then
    hangupType=2
    hangupCause = "fs挂机"
    return 
  else if sip_hangup_disposition == "" then
    hangupType=1
    hangupCause = "客户挂机"
  end

end

freeswitch.consoleLog("INFO","env:\n-----------------" .. hangupCause .. "---------" .. callerIdNumber .."-----" .. sip_hangup_disposition .. "-----\n")
local hangupType, hangupCause = getHangupTypeAndHangupCause(hangupCause, callerIdNumber, sip_hangup_disposition, sip_term_status)
freeswitch.consoleLog("INFO","res:\n-----------------" .. hangupType .. "---------" .. hangupCause .."----------\n")

 

参考:

__Channel Variables | FreeSWITCH Documentation

Hangup Cause Code Table | FreeSWITCH Documentation

Lua API Reference | FreeSWITCH Documentation

Lua examples | FreeSWITCH Documentation

 

 

转载请注明:SuperIT » freeswitch挂断原因处理

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!