<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head><meta http-equiv="Content-Type" content="text/html;charset=us-ascii">
<style>BODY{font:10pt Tahoma, Verdana, sans-serif}</style></head><body>
<DIV>You want to return a string that is the XML of what the users directory entry would look like. Do lookup in database, etc..</DIV>
<DIV> </DIV>
<DIV>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. </DIV>
<DIV> </DIV>
<DIV>--Dave</DIV><BR>
<BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<HR>
<B>From:</B> Samira Mh [mailto:saami_mh@ymail.com]<BR><B>To:</B> Free SWITCH Users Help [mailto:freeswitch-users@lists.freeswitch.org]<BR><B>Sent:</B> Sun, 24 Jun 2012 06:50:09 -0700<BR><B>Subject:</B> [Freeswitch-users] question on mod_lua for serving_configurations(implement realtime in freeswitch)?<BR><BR>
<DIV style="BACKGROUND-COLOR: #fff; FONT-FAMILY: times new roman, new york, times, serif; COLOR: #000; FONT-SIZE: 12pt">
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt">hi,</DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt">in mod_lua for Serving_Configuration ( <SPAN style="BORDER-BOTTOM: rgb(54,99,136) 2px dotted; BACKGROUND-COLOR: rgb(220,238,255); OUTLINE-WIDTH: 0px; FONT-FAMILY: Arial, Helvetica, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 12px; CURSOR: pointer" id=lw_1340509000_0 class=yshortcuts><A style="OUTLINE-WIDTH: 0px; FONT-FAMILY: Arial, Helvetica, sans-serif; COLOR: rgb(58,101,187); FONT-SIZE: 12px" href="http://wiki.freeswitch.org/wiki/Mod_lua/Serving_Configuration">http://wiki.freeswitch.org/wiki/Mod_lua/Serving_Configuration</A> ) </SPAN><SPAN style="FONT-SIZE: 12pt">i have defined the settings as follows:</SPAN></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><SPAN style="FONT-SIZE: 12pt">1-</SPAN></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><SPAN style="FONT-SIZE: 12pt"><BR></SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"> </SPAN><FONT face="'times new roman', 'new york', times, serif"><configuration name="lua.conf" description="LUA Configuration"><BR></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"> <settings></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"><BR></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"> </FONT><SPAN style="FONT-FAMILY: 'times new roman', 'new york', times, serif"> <param name="xml-handler-script" value="dp.lua"/></SPAN></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"> <param name="xml-handler-bindings" value="directory"/></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"> </FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"> </settings></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"></configuration></FONT></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt">2- /usr/local/freeswitch/scripts/dp.lua</DIV>
<DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "SECTION " .. XML_REQUEST["section"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "TAG_NAME " .. XML_REQUEST["tag_name"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "KEY_NAME " .. XML_REQUEST["key_name"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "KEY_VALUE " .. XML_REQUEST["key_value"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif"><BR></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO",params:serialize())</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">io.write("TEST \n" .. params:serialize("xml") .. "\n");</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">--io.write("SIP_AUTH_METHOD\n" .. params:getHeader("sip_auth_method") .. "\n");</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">--io.write("sip_profile\n" .. params:getHeader("sip_profile") .. "\n");</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">local sipprofile = params:getHeader("sip_profile");</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">print ("sip profile is:" .. sipprofile);</FONT></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt">3- the output of the above lua file is :</DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV>
<DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">
<DIV>TEST</DIV>
<DIV><event></DIV>
<DIV> <headers></DIV>
<DIV> <Event-Name>REQUEST_PARAMS</Event-Name></DIV>
<DIV> <Core-UUID>1d640ebe-be01-11e1-b2cd-4109894802cc</Core-UUID></DIV>
<DIV> <FreeSWITCH-Hostname>PBX</FreeSWITCH-Hostname></DIV>
<DIV> <FreeSWITCH-Switchname>PBX</FreeSWITCH-Switchname></DIV>
<DIV> <FreeSWITCH-IPv4>192.168.10.89</FreeSWITCH-IPv4></DIV>
<DIV> <FreeSWITCH-IPv6>%3A%3A1</FreeSWITCH-IPv6></DIV>
<DIV> <Event-Date-Local>2012-06-24%2018%3A13%3A48</Event-Date-Local></DIV>
<DIV> <Event-Date-GMT>Sun,%2024%20Jun%202012%2013%3A43%3A48%20GMT</Event-Date-GMT></DIV>
<DIV> <Event-Date-Timestamp>1340545428075826</Event-Date-Timestamp></DIV>
<DIV> <Event-Calling-File>sofia_reg.c</Event-Calling-File></DIV>
<DIV> <Event-Calling-Function>sofia_reg_parse_auth</Event-Calling-Function></DIV>
<DIV> <Event-Calling-Line-Number>2364</Event-Calling-Line-Number></DIV>
<DIV> <Event-Sequence>1240</Event-Sequence></DIV>
<DIV> <action>sip_auth</action></DIV>
<DIV> <sip_profile>internal</sip_profile></DIV>
<DIV> <sip_user_agent>eyeBeam%20release%201102q%20stamp%2051814</sip_user_agent></DIV>
<DIV> <sip_auth_username>1000</sip_auth_username></DIV>
<DIV> <sip_auth_realm>192.168.10.89</sip_auth_realm></DIV>
<DIV> <sip_auth_nonce>5fef3276-be02-11e1-b2fd-4109894802cc</sip_auth_nonce></DIV>
<DIV> <sip_auth_uri>sip%3A192.168.10.89</sip_auth_uri></DIV>
<DIV> <sip_contact_user>1000</sip_contact_user></DIV>
<DIV> <sip_contact_host>192.168.18.120</sip_contact_host></DIV>
<DIV> <sip_to_user>1000</sip_to_user></DIV>
<DIV> <sip_to_host>192.168.10.89</sip_to_host></DIV>
<DIV> <sip_from_user>1000</sip_from_user></DIV>
<DIV> <sip_from_host>192.168.10.89</sip_from_host></DIV>
<DIV> <sip_request_host>192.168.10.89</sip_request_host></DIV>
<DIV> <sip_auth_qop>auth</sip_auth_qop></DIV>
<DIV> <sip_auth_cnonce>8725f832cb29a466ba073ef5d63de959</sip_auth_cnonce></DIV>
<DIV> <sip_auth_nc>00000010</sip_auth_nc></DIV>
<DIV> <sip_auth_response>ee0155cd5b41536e56898ff585502e75</sip_auth_response></DIV>
<DIV> <sip_auth_method>REGISTER</sip_auth_method></DIV>
<DIV> <key>id</key></DIV>
<DIV> <user>1000</user></DIV>
<DIV> <domain>192.168.10.89</domain></DIV>
<DIV> <ip>192.168.18.120</ip></DIV>
<DIV> </headers></DIV>
<DIV></event></DIV>
<DIV><BR></DIV>
<DIV>sip profile is :internal<BR></DIV>
<DIV>---------------------------------------------------</DIV>
<DIV><BR></DIV>
<DIV>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 </DIV>
<DIV>what is the next step for implementing? <BR></DIV>
<DIV>Now need to define mysql and insert query in lua script and compare the query with the value of params:getHeader ?</DIV>
<DIV>the resource for mod_lua serving configuration is a bit<BR></DIV>
<DIV><BR></DIV>
<DIV>plz help, </DIV>
<DIV>thanks so much</DIV>
<DIV><BR></DIV></FONT></DIV>
<DIV style="FONT-FAMILY: 'times new roman', 'new york', times, serif; FONT-SIZE: 12pt"><BR></DIV></DIV></DIV></BLOCKQUOTE>
<STYLE>
</STYLE>
<DIV> </DIV>
<DIV> </DIV></body></html>