[Freeswitch-users] question on mod_lua for serving_configurations(implement realtime in freeswitch)?

Dave R. Kompel drk at drkngs.net
Sun Jun 24 23:02:09 MSD 2012


You want to return a string that is the XML of what the users directory entry would look like. Do lookup in database, etc..  
   
If the user is not found you either want to return NULL, which will cause it to continue and check the XML, or return the 'not found document' just like in XML_CURL that will end the search.   
   
--Dave
      _____  

  From: Samira Mh [mailto:saami_mh at ymail.com]
To: Free SWITCH Users Help [mailto:freeswitch-users at lists.freeswitch.org]
Sent: Sun, 24 Jun 2012 06:50:09 -0700
Subject: [Freeswitch-users] question on mod_lua for serving_configurations(implement realtime in freeswitch)?

  
  
hi,  
in mod_lua for Serving_Configuration ( http://wiki.freeswitch.org/wiki/Mod_lua/Serving_Configuration ) i have defined the settings as follows:  
1-  

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

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

  
2- /usr/local/freeswitch/scripts/dp.lua  
  
freeswitch.consoleLog("INFO", "SECTION    " .. XML_REQUEST["section"] .. "\n")  
freeswitch.consoleLog("INFO", "TAG_NAME   " .. XML_REQUEST["tag_name"] .. "\n")  
freeswitch.consoleLog("INFO", "KEY_NAME   " .. XML_REQUEST["key_name"] .. "\n")  
freeswitch.consoleLog("INFO", "KEY_VALUE  " .. XML_REQUEST["key_value"] .. "\n")  

  
freeswitch.consoleLog("INFO",params:serialize())  
io.write("TEST \n" .. params:serialize("xml") .. "\n");  
--io.write("SIP_AUTH_METHOD\n" .. params:getHeader("sip_auth_method") .. "\n");  
--io.write("sip_profile\n" .. params:getHeader("sip_profile") .. "\n");  
local sipprofile = params:getHeader("sip_profile");  
print ("sip profile is:" .. sipprofile);  

  
3- the output of the above lua file is :  

  

  

  
  
  
TEST  
<event>  
  <headers>  
    <Event-Name>REQUEST_PARAMS</Event-Name>  
    <Core-UUID>1d640ebe-be01-11e1-b2cd-4109894802cc</Core-UUID>  
    <FreeSWITCH-Hostname>PBX</FreeSWITCH-Hostname>  
    <FreeSWITCH-Switchname>PBX</FreeSWITCH-Switchname>  
    <FreeSWITCH-IPv4>192.168.10.89</FreeSWITCH-IPv4>  
    <FreeSWITCH-IPv6>%3A%3A1</FreeSWITCH-IPv6>  
    <Event-Date-Local>2012-06-24%2018%3A13%3A48</Event-Date-Local>  
    <Event-Date-GMT>Sun,%2024%20Jun%202012%2013%3A43%3A48%20GMT</Event-Date-GMT>  
    <Event-Date-Timestamp>1340545428075826</Event-Date-Timestamp>  
    <Event-Calling-File>sofia_reg.c</Event-Calling-File>  
    <Event-Calling-Function>sofia_reg_parse_auth</Event-Calling-Function>  
    <Event-Calling-Line-Number>2364</Event-Calling-Line-Number>  
    <Event-Sequence>1240</Event-Sequence>  
    <action>sip_auth</action>  
    <sip_profile>internal</sip_profile>  
    <sip_user_agent>eyeBeam%20release%201102q%20stamp%2051814</sip_user_agent>  
    <sip_auth_username>1000</sip_auth_username>  
    <sip_auth_realm>192.168.10.89</sip_auth_realm>  
    <sip_auth_nonce>5fef3276-be02-11e1-b2fd-4109894802cc</sip_auth_nonce>  
    <sip_auth_uri>sip%3A192.168.10.89</sip_auth_uri>  
    <sip_contact_user>1000</sip_contact_user>  
    <sip_contact_host>192.168.18.120</sip_contact_host>  
    <sip_to_user>1000</sip_to_user>  
    <sip_to_host>192.168.10.89</sip_to_host>  
    <sip_from_user>1000</sip_from_user>  
    <sip_from_host>192.168.10.89</sip_from_host>  
    <sip_request_host>192.168.10.89</sip_request_host>  
    <sip_auth_qop>auth</sip_auth_qop>  
    <sip_auth_cnonce>8725f832cb29a466ba073ef5d63de959</sip_auth_cnonce>  
    <sip_auth_nc>00000010</sip_auth_nc>  
    <sip_auth_response>ee0155cd5b41536e56898ff585502e75</sip_auth_response>  
    <sip_auth_method>REGISTER</sip_auth_method>  
    <key>id</key>  
    <user>1000</user>  
    <domain>192.168.10.89</domain>  
    <ip>192.168.18.120</ip>  
  </headers>  
</event>  

  
sip profile is :internal
  
---------------------------------------------------  

  
Now i am going to check  using reltime every user that registers on sip phone -like 3CXphone - instead of in-memory method (flat file on freeswitch), now   
what is the next step for implementing? 
  
Now  need to define mysql and insert query  in lua script and compare the query with the value of params:getHeader ?  
the resource for mod_lua serving configuration is a bit
  

  
plz help,   
thanks so much  

  

      
   
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120624/adb9e560/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list