【问题标题】:How to use the Lua management freeswitch gatewayLua管理freeswitch网关的使用方法
【发布时间】:2015-04-30 02:30:11
【问题描述】:

全部

 I want to manage freeswitch gateway by lua,how to do it?
 such as:


   <configuration name="lua.conf" description="LUA Configuration">
  <settings>

    <param name="xml-handler-script" value="gen_dir_user_xml.lua" />
    <param name="xml-handler-bindings" value="directory" />

  </settings>
</configuration>

这是管理用户配置。 谢谢


为什么要添加lua代码?这个问题是必需的配置文件和任何lua代码,但它有lua代码..用户管理lua代码:

local req_domain = params:getHeader("domain")
local req_key    = params:getHeader("key")
local req_user   = params:getHeader("user")
local req_password   = params:getHeader("pass")

local dbh = freeswitch.Dbh("freeswitch","postgres","tttt");
freeswitch.consoleLog("NOTICE","start connect DB...\r\n");
assert(dbh:connected());
dbh:query("select password from users where id="..req_user,function(row)
        freeswitch.consoleLog("NOTICE",string.format("%s\n",row.password))
        req_password=string.format("%s",row.password)
end);
dbh:release();

freeswitch.consoleLog("NOTICE","info:"..req_domain.."--"..req_key.."--"..req_user.."--"..req_password.."\n");



--assert (req_domain and req_key and req_user,
--"This example script only supports generating directory xml for a single user !\n")
if req_domain ~= nil and req_key~=nil and req_user~=nil then
    XML_STRING =
    [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <document type="freeswitch/xml">
      <section name="directory">
        <domain name="]]..req_domain..[[">
          <params>
        <param name="dial-string"
        value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
          </params>
          <groups>
        <group name="default">
          <users>
            <user id="]] ..req_user..[[">
              <params>
            <param name="password" value="]]..req_password..[["/>
            <param name="vm-password" value="]]..req_password..[["/>
              </params>
              <variables>
            <variable name="toll_allow" value="domestic,international,local"/>
            <variable name="accountcode" value="]] ..req_user..[["/>
            <variable name="user_context" value="default"/>
            <variable name="directory-visible" value="true"/>
            <variable name="directory-exten-visible" value="true"/>
            <variable name="limit_max" value="15"/>
            <variable name="effective_caller_id_name" value="Extension ]] ..req_user..[["/>
            <variable name="effective_caller_id_number" value="]] ..req_user..[["/>
            <variable name="outbound_caller_id_name" value="${outbound_caller_name}"/>
            <variable name="outbound_caller_id_number" value="${outbound_caller_id}"/>
            <variable name="callgroup" value="techsupport"/>
              </variables>
            </user>
          </users>
        </group>
          </groups>
        </domain>
      </section>
    </document>]]
else
    XML_STRING =
    [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <document type="freeswitch/xml">
      <section name="directory">
      </section>
    </document>]]
end

【问题讨论】:

  • 那里没有lua代码
  • 为什么要添加lua代码?这个问题是必需的配置文件和任何 lua 代码,但它有 lua 代码.. 用户管理 lua 代码所以:

标签: lua gateway freeswitch


【解决方案1】:

看看fusionpbx源码,里面有很多Lua代码。

【讨论】:

    猜你喜欢
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多