2015-04-30 3 views
0

всеКак использовать Lua управления FreeSwitch Шлюз по

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 
+0

Нет кода lua там – hjpotter92

+0

почему добавить код lua? для этого вопроса требуется файл конфигурации и любой код lua, но он имеет код lua .. код управления lua для пользователя: – lihao

ответ

0

Посмотрите на исходный код fusionpbx, он имеет много Lua кода.

Смежные вопросы