<div>Hi Michael,</div><div> </div><div>Thanks for the interjection :) it is not specially for billing, though I need the hangup to cleanup a lot of database stuff (using stored procedures). My plan was to finalize my data using the hangup and using some other mechanism to finalize my billing data (for example using the mod_xml_cdr to trigger the end of the call).</div>
<div> </div><div>But as I am also going to dialout and bridge calls I also need it to be able to detect the aleg hung up and disconnect the bleg? Or are there other ways to do that?</div><div> </div><div>For example I want to do something like: (example code written for mod_managed wich I did&#39;t get to work: (leg_a and leg_b.bridged return false after connecting))</div>
<div> </div><div>            route = &quot;3112345678&quot; // Number to dial<br>            string obCause = &quot;ERROR&quot;;<br>            FreeSWITCH.Native.Api fsApi = new FreeSWITCH.Native.Api();<br>            <br>
            //  Creating the new session...<br>            ManagedSession leg_b = new ManagedSession(&quot;{ignore_early_media=true,origination_caller_id_number=&quot; + orig + &quot;,originate_timeout=20}sofia/external/&quot; + route);<br>
            if (leg_b.Ready())<br>            {<br>                if (leg_b.answered())<br>                {<br>                    MCX.AnswerCall(leg_a);   // answer the incomming call as it was in &#39;ring_ready&#39;<br>
                    leg_a.sleep(1000, 0);</div><div>                    string apiResult = fsApi.ExecuteString(string.Format(&quot;uuid_bridge {1} {0}&quot;, leg_a.GetUuid(), leg_b.GetUuid()));<br>                    obCause = &quot;SUCCESS&quot;;</div>
<div>                    Debug(&quot;As long as both legs are Ready(), we wait......&quot;);<br>                    while (leg_a.bridged() &amp;&amp; leg_b.bridged())  // Returns false right away (bug?)<br>                    {<br>
                        leg_a.sleep(1000, 0); // Slow it down...<br>                    }</div><div>                    Debug(&quot;There is one leg no longer ready...&quot;);<br>                    if (leg_a.bridged()) { Debug(&quot;Session A still ready...&quot;); } else { Debug(&quot;Session A NO LONGER ready...&quot;); }<br>
                    if (leg_b.bridged()) { Debug(&quot;Session B still ready...&quot;); } else { Debug(&quot;Session B NO LONGER ready...&quot;); }<br>                }<br>                else<br>                {<br>                    Debug(&quot;A-Leg aborted while dialing...&quot;);<br>
                }<br>                /*<br>                if (leg_b.Ready())<br>                {<br>                    Debug(&quot;B-Leg still here, so hanging up B-Leg...&quot;);<br>                    leg_b.Hangup(&quot;NORMAL_CALL_CLEARING&quot;);<br>
                    leg_b.destroy();<br>                }<br>                 * */<br>            }<br>            else<br>            {<br>                obCause = leg_b.hangupCause();<br>            }<br>            Debug(&quot;simpleCall() ended with: &quot; + obCause);<br>
            return obCause;<br>        }<br></div><div>Can you help me on how to do this in managedESL ?<br></div><div> </div><div>Thanks,</div><div>Mike<br> </div><div class="gmail_quote">2012/1/13 Michael Giagnocavo <span dir="ltr">&lt;<a href="mailto:mgg@giagnocavo.net">mgg@giagnocavo.net</a>&gt;</span><br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div lang="EN-US" vlink="purple" link="blue"><div><p class="MsoNormal">
<span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">What do you need to catch hangup for? If it’s for accounting, I’ll repeat my general lesson that I painfully learned. Don’t do it. Antony and I spent quite some time trying to sort out problems related to doing accounting “in-call”, all the while they were telling me to not do it. I ended up with a lot of hacky code that sorta worked most of the time. A much better approach is to set vars on the channel and collect them when the XML CDR is written. If you need real-time accounting, just log the call once it opens to a database, and calculate outstanding balance from there.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">If it’s another thing you’re trying to do on hangup, excuse my interjection here </span><span style="color:rgb(31,73,125);font-family:Wingdings;font-size:11pt">J</span><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">-Michael<u></u><u></u></span></p><p class="MsoNormal"><a name="134d74dd06fcd6e0__MailEndCompose"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt">From:</span></b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt"> <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a> [mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b>On Behalf Of </b>Michael Lutz<br>
<b>Sent:</b> Friday, January 13, 2012 6:31 AM<br><b>To:</b> FreeSWITCH Users Help<br><b>Subject:</b> Re: [Freeswitch-users] ESL Managed IVR and CallControl<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal">
<u></u> <u></u></p><div><p class="MsoNormal">Hi Hector,<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Thanks for your reply. I am trying the provided ManagedEsl test project now. It seems to do what I want but having much trouble trying to add functionality. I hope someone here can help me with a better server example with esl in outbound mode.<u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">I am also wondering how to set eventhandlers for dtmf or channel hangup events? <u></u><u></u></p></div><div><p class="MsoNormal">Is there anyone here that can help me with some examples?<u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">For example I need to be able to catch the hangup or be able to respond to dtmfs.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p>
</div><div><p class="MsoNormal">Thanks,<u></u><u></u></p></div><div><p style="margin-bottom:12pt" class="MsoNormal">Mike.<u></u><u></u></p></div><div><p class="MsoNormal">2012/1/12 Hector Geraldino &lt;<a href="mailto:Hector.Geraldino@ip-soft.net" target="_blank">Hector.Geraldino@ip-soft.net</a>&gt;<u></u><u></u></p>
<div><div><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">I have experience setting up something like that, but in Java.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">You should use ESL in outbound mode. For every new incoming call, FS will open a socket connection to an ip:port where your application should be listening to, and you will have complete control over the incoming call. So, in theory, you should only need to have a SocketServer listening to an specific port, and send commands/receive events from FS to your application (you can play a little bit with this in linux using the netcat (nc) utility, or maybe in windows by installing Cygwin  and using nc.exe)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">I’m happy using the Java ESL library, a pure socket-based java application (jboss/netty based) with no dependencies on system libs.  Maybe (and this is a BIG MAYBE) you can reuse this library from .NET, relying on Mono’s IKVM tool, that allows Java-to-NET interoperability by converting Java’s JVM bytecode to .NET CLR. I’ve taken this approach before, when I found a terrific tool in Java (jPOS, for example) with no counterparts in .NET.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">This is only one option. There’s always the option of building your own application listening on a socket, or using the .NET libraries listed on the wiki:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"> </span><u></u><u></u></p><p class="MsoNormal"><a href="http://wiki.freeswitch.org/wiki/Mod_event_socket#.NET_Client_library" target="_blank">http://wiki.freeswitch.org/wiki/Mod_event_socket#.NET_Client_library</a><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">Good luck! </span><u></u><u></u></p><p class="MsoNormal">
<span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"> </span><u></u><u></u></p><div style="border-width:1pt medium medium;border-style:solid none none;border-color:currentColor;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt">From:</span></b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt"> <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a> [mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b>On Behalf Of </b>Michael Lutz<br>
<b>Sent:</b> Thursday, January 12, 2012 10:02 AM<br><b>To:</b> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br><b>Subject:</b> [Freeswitch-users] ESL Managed IVR and CallControl</span><u></u><u></u></p>
</div><div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">Hi,<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">I have been playing with mod_managed for a while now but nobody realy seems to be able to help me out. So now I am trying to go to ESL. (which most of the people suggest anyway).<u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">What I need is control from .net over the complete call! (so even when bridged and returns). <u></u><u></u></p></div><div><p class="MsoNormal">
 <u></u><u></u></p></div><div><p class="MsoNormal">I need to build  a main library where all my generic functions will be put in so I can use them in my different scripts.<u></u><u></u></p></div><div><p class="MsoNormal">
 <u></u><u></u></p></div><div><p class="MsoNormal">What I&#39;&#39;ve figured out is problably the best way is to write a server which connects to my FS an listens to all events.<u></u><u></u></p></div><div><p class="MsoNormal">
When a call comes in I need to fire a stored procedure to my sqlserver and based on the reply I will decide if the call needsto be answerred, early media needs to be played, or the call needs to be rejected.<u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">In any case, at the end of every call (answered or not) I need to finalize my call with another stored procedure.<u></u><u></u></p></div><div>
<p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">When teh call is answered based on stored procedure result I need to run a script (also managed code) <u></u><u></u></p></div><div><p class="MsoNormal">
run a script from another dll so I have all my scripts separate but they share the corelib I create.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">I have been searching the web for a long time now to see if I can find something simular, but I only see generic examples wich don&#39;t actually show how to control multiple calls in a scenario like this.<u></u><u></u></p>
</div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Who can help me out point me to the right direction or has experience in setting something up like this?<u></u><u></u></p></div><div><p class="MsoNormal">
 <u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Thanks in advance,<u></u><u></u></p></div><div><p class="MsoNormal">Michael Lutz.<u></u><u></u></p></div><div><p class="MsoNormal">
 <u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div></div></div></div></div><p style="margin-bottom:12pt" class="MsoNormal"><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br><a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br><a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br><a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br><br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br><a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br><br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div><br>_________________________________________________________________________<br>

Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>