<!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>&nbsp;</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>&nbsp;</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 (&nbsp;<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>&nbsp;)&nbsp;</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">&nbsp;</SPAN><FONT face="'times new roman', 'new york', times, serif">&lt;configuration name="lua.conf" description="LUA Configuration"&gt;<BR></FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">&nbsp; &lt;settings&gt;</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">&nbsp; &nbsp;</FONT><SPAN style="FONT-FAMILY: 'times new roman', 'new york', times, serif">&nbsp; &nbsp; &lt;param name="xml-handler-script" value="dp.lua"/&gt;</SPAN></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &lt;param name="xml-handler-bindings" value="directory"/&gt;</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &nbsp; &nbsp;</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">&nbsp; &lt;/settings&gt;</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">&lt;/configuration&gt;</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-&nbsp;/usr/local/freeswitch/scripts/dp.lua</DIV>
<DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "SECTION &nbsp; &nbsp;" .. XML_REQUEST["section"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "TAG_NAME &nbsp; " .. XML_REQUEST["tag_name"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "KEY_NAME &nbsp; " .. XML_REQUEST["key_name"] .. "\n")</FONT></DIV>
<DIV><FONT face="'times new roman', 'new york', times, serif">freeswitch.consoleLog("INFO", "KEY_VALUE &nbsp;" .. 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>&lt;event&gt;</DIV>
<DIV>&nbsp; &lt;headers&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Name&gt;REQUEST_PARAMS&lt;/Event-Name&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Core-UUID&gt;1d640ebe-be01-11e1-b2cd-4109894802cc&lt;/Core-UUID&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;FreeSWITCH-Hostname&gt;PBX&lt;/FreeSWITCH-Hostname&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;FreeSWITCH-Switchname&gt;PBX&lt;/FreeSWITCH-Switchname&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;FreeSWITCH-IPv4&gt;192.168.10.89&lt;/FreeSWITCH-IPv4&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;FreeSWITCH-IPv6&gt;%3A%3A1&lt;/FreeSWITCH-IPv6&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Date-Local&gt;2012-06-24%2018%3A13%3A48&lt;/Event-Date-Local&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Date-GMT&gt;Sun,%2024%20Jun%202012%2013%3A43%3A48%20GMT&lt;/Event-Date-GMT&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Date-Timestamp&gt;1340545428075826&lt;/Event-Date-Timestamp&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Calling-File&gt;sofia_reg.c&lt;/Event-Calling-File&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Calling-Function&gt;sofia_reg_parse_auth&lt;/Event-Calling-Function&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Calling-Line-Number&gt;2364&lt;/Event-Calling-Line-Number&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;Event-Sequence&gt;1240&lt;/Event-Sequence&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;action&gt;sip_auth&lt;/action&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_profile&gt;internal&lt;/sip_profile&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_user_agent&gt;eyeBeam%20release%201102q%20stamp%2051814&lt;/sip_user_agent&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_username&gt;1000&lt;/sip_auth_username&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_realm&gt;192.168.10.89&lt;/sip_auth_realm&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_nonce&gt;5fef3276-be02-11e1-b2fd-4109894802cc&lt;/sip_auth_nonce&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_uri&gt;sip%3A192.168.10.89&lt;/sip_auth_uri&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_contact_user&gt;1000&lt;/sip_contact_user&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_contact_host&gt;192.168.18.120&lt;/sip_contact_host&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_to_user&gt;1000&lt;/sip_to_user&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_to_host&gt;192.168.10.89&lt;/sip_to_host&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_from_user&gt;1000&lt;/sip_from_user&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_from_host&gt;192.168.10.89&lt;/sip_from_host&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_request_host&gt;192.168.10.89&lt;/sip_request_host&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_qop&gt;auth&lt;/sip_auth_qop&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_cnonce&gt;8725f832cb29a466ba073ef5d63de959&lt;/sip_auth_cnonce&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_nc&gt;00000010&lt;/sip_auth_nc&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_response&gt;ee0155cd5b41536e56898ff585502e75&lt;/sip_auth_response&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;sip_auth_method&gt;REGISTER&lt;/sip_auth_method&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;key&gt;id&lt;/key&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;user&gt;1000&lt;/user&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;domain&gt;192.168.10.89&lt;/domain&gt;</DIV>
<DIV>&nbsp; &nbsp; &lt;ip&gt;192.168.18.120&lt;/ip&gt;</DIV>
<DIV>&nbsp; &lt;/headers&gt;</DIV>
<DIV>&lt;/event&gt;</DIV>
<DIV><BR></DIV>
<DIV>sip profile is&nbsp;:internal<BR></DIV>
<DIV>---------------------------------------------------</DIV>
<DIV><BR></DIV>
<DIV>Now i am going to check &nbsp;using reltime every user that registers on sip phone -like 3CXphone - instead of in-memory method (flat file on freeswitch), now&nbsp;</DIV>
<DIV>what is the next step for implementing?&nbsp;<BR></DIV>
<DIV>Now &nbsp;need to define mysql and insert query &nbsp;in lua script and compare the query with the value of&nbsp;params:getHeader ?</DIV>
<DIV>the resource for mod_lua serving configuration is a bit<BR></DIV>
<DIV><BR></DIV>
<DIV>plz help,&nbsp;</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>&nbsp;</DIV>
<DIV>&nbsp;</DIV></body></html>