<div>Hi,</div><div> </div><div>I did managed to get something to work. I placed complete code on pastebin: <a href="http://pastebin.com/eCsYSdfk">http://pastebin.com/eCsYSdfk</a> I don&#39;t know why exactly it works now, I think it has something to do with a public decalration of my leg_a as managed session and using that, now I pass the contect.Session every time and create that as a local leg_a reference and that seems to work...</div>
<div> </div><div>Still I have some problems with I need realy need somebody to help me with...</div><div> </div><div>1. immediately after the bridge (log says exact same timestamp) the HangUp handler is invoked. (it seems as a separate part, as the rest of my code is handled too) Why is the hangup handler called when the bridge is started and how to avoid this?</div>
<div> </div><div>2. After the bridge I need to get into a loop to continue my code while in the bridge, and after the bridge, depending on who hung up. So after bridge I go into while loop like:</div><div>     while(leg_a.bridged() &amp;&amp; leg_b.bridged()) { }</div>
<div>But the both return false immediately. Al other functions ( contect.Session.Ready() ) return false too, though my code continues and just continues my function. How can I make this work?</div><div> </div><div>My (custom debug)log shows:</div>
<div>2012-01-09 10:29:42.111746 [INFO] sofia.c:819 <a href="mailto:sofia/internal/****@*.*.*.*">sofia/internal/****@*.*.*.*</a> Update Callee ID to &quot;HW-MIKE-TC01&quot; &lt;3120*******&gt;<br>2012-01-09 10:29:42.993834 [INFO] switch_channel.c:2708 <a href="mailto:sofia/external/***********@*.*.*.*">sofia/external/***********@*.*.*.*</a> Flipping CID from &quot;&quot; &lt;313*********&gt; to &quot;Outbound Call&quot; &lt;316*********&gt;<br>
2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; HandleHangUp();<br>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; Finalizing call in CDR table<br>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; apiResult=+OK 792d63a7-fa2e-43fb-b43b-32c11e2b7452</div>
<div>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; As long as both legs are Ready(), we wait......<br>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; There is one leg no longer ready...<br>
2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; Session A NO LONGER ready...<br>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; Session B NO LONGER ready...<br>2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; SimpleCall() ended with: SUCCESS<br>
2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============&gt; End of run...</div><div> </div><div>Then when I realy hangup:<br>2012-01-09 10:31:13.386873 [NOTICE] sofia.c:623 Hangup <a href="mailto:sofia/external/316********@*.*.*.*">sofia/external/316********@*.*.*.*</a> [CS_SOFT_EXECUTE] [NORMAL_CLEARING]<br>
2012-01-09 10:31:13.406875 [NOTICE] switch_ivr_bridge.c:669 Hangup <a href="mailto:sofia/internal/3120********@*.*.*.*">sofia/internal/3120********@*.*.*.*</a> [CS_EXCHANGE_MEDIA] [NORMAL_CLEARING]<br>2012-01-09 10:31:13.406875 [NOTICE] switch_core_session.c:1398 Session 133 (<a href="mailto:sofia/internal/3120*******@*.*.*.*">sofia/internal/3120*******@*.*.*.*</a>) Ended<br>
2012-01-09 10:31:13.406875 [NOTICE] switch_core_session.c:1400 Close Channel <a href="mailto:sofia/internal/3120*******@*.*.*.*">sofia/internal/3120*******@*.*.*.*</a> [CS_DESTROY]</div><div> </div><div> </div><div> </div>
<div>Thanks in advance!</div><div> </div><div>Regards,</div><div>Mike.<br><br> </div><div class="gmail_quote">2012/1/6 Michael Lutz <span dir="ltr">&lt;<a href="mailto:mytemike72@gmail.com">mytemike72@gmail.com</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">I allready did paste logs last week on request... What logs do you want?<br>

<br>
Regards,<br>
Mike<br>
<br>
<br>
Op 6 jan. 2012 om 17:45 heeft Peter Olsson &lt;<a href="mailto:peter.olsson@visionutveckling.se">peter.olsson@visionutveckling.se</a>&gt; het volgende geschreven:<br>
<div class="HOEnZb"><div class="h5"><br>
&gt; Please pastebin some debug logs, so we know where to start looking.<br>
&gt;<br>
&gt; /Peter<br>
&gt; ________________________________<br>
&gt; Från: <a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org">freeswitch-dev-bounces@lists.freeswitch.org</a> [<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org">freeswitch-dev-bounces@lists.freeswitch.org</a>] för Michael Lutz [<a href="mailto:mytemike72@gmail.com">mytemike72@gmail.com</a>]<br>

&gt; Skickat: den 6 januari 2012 16:56<br>
&gt; Till: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>
&gt; Ämne: Re: [Freeswitch-dev] bridging calls using mod_managed<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; Anyone here who can help me with this problem? I got really stuck on this one..<br>
&gt;<br>
&gt; Thanks for helping!,<br>
&gt; Mike<br>
&gt;<br>
&gt; Op 4 jan. 2012 om 18:58 heeft Michael Giagnocavo &lt;<a href="mailto:mgg@giagnocavo.net">mgg@giagnocavo.net</a>&lt;mailto:<a href="mailto:mgg@giagnocavo.net">mgg@giagnocavo.net</a>&gt;&gt; het volgende geschreven:<br>

&gt;<br>
&gt; Can you paste the debug log from FreeSWITCH when this happens?<br>
&gt;<br>
&gt; From: <a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org">freeswitch-dev-bounces@lists.freeswitch.org</a>&lt;mailto:<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org">freeswitch-dev-bounces@lists.freeswitch.org</a>&gt; [mailto:<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org">freeswitch-dev-bounces@lists.freeswitch.org</a>] On Behalf Of Michael Lutz<br>

&gt; Sent: Wednesday, January 04, 2012 10:10 AM<br>
&gt; To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a>&lt;mailto:<a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a>&gt;<br>
&gt; Subject: [Freeswitch-dev] bridging calls using mod_managed<br>
&gt;<br>
&gt;<br>
&gt; Hi,<br>
&gt; I&#39;ve been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls.<br>

&gt; This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active.<br>
&gt; I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects.<br>
&gt; This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect.<br>
&gt; Hoewever at some point I want to dialout to an external number and connect these two calls together.<br>
&gt; I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call).  While these two are connected I need to update my database periodicaly (keepalive).<br>

&gt; I have been looking the internet to find what I need but i can&#39;t get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.<br>
&gt;<br>
&gt; I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch).<br>

&gt;<br>
&gt;                    Debug(&quot;Got a route=&gt;&quot;+route+&quot;, Let the network play the ringtone...&quot;);<br>
&gt;                    leg_a.Execute(&quot;ring_ready&quot;, &quot;&quot;);<br>
&gt;<br>
&gt;                    Debug(&quot;Creating the new session...&quot;);<br>
&gt;                    ManagedSession leg_b = new ManagedSession(&quot;sofia/external/&quot;+route);  // route holds {destinationNumber}@{myExternalGateway&lt;mailto:%7bdestinationNumber%7d@%7bmyExternalGateway&gt;}<br>

&gt;                    if (leg_b.Ready())<br>
&gt;                    {<br>
&gt;                        Debug(&quot;Session_B ready!&quot;);<br>
&gt;                        string fsuuid_b = leg_b.GetVariable(&quot;uuid&quot;);<br>
&gt;<br>
&gt;                        Debug(&quot;Waiting for B-Leg to answer and A-Leg not to hangup...&quot;);<br>
&gt;                        while (!leg_b.answered() &amp;&amp; leg_a.Ready() ) { /* Ringing... */ }<br>
&gt;<br>
&gt;                        if (leg_b.answered())<br>
&gt;                        {<br>
&gt;                            Debug(&quot;...B-Leg is answered&quot;);<br>
&gt;                            AnswerCall(leg_a);<br>
&gt;                            while (!leg_a.answered()) { }<br>
&gt;                            Debug(&quot;...A-Leg is answered&quot;);<br>
&gt;<br>
&gt;                            // ****** BRIDGE SHOULD BE HERE ******<br>
&gt;<br>
&gt;                            Debug(&quot;As long as both legs are Ready(), we wait......&quot;);<br>
&gt;                            while (leg_b.Ready() &amp;&amp; leg_a.Ready())<br>
&gt;                            {<br>
&gt;                                Play(leg_b, &quot;Test\\dir-no_matching_results.wav&quot;); // REMOVE WHEN BRIDGED<br>
&gt;                                Play(leg_a, &quot;Test\\dir-no_matching_results.wav&quot;); // REMOVE WHEN BRIDGED<br>
&gt;                            }<br>
&gt;<br>
&gt;                            Debug(&quot;There is one leg no longer ready...&quot;);<br>
&gt;                            if (leg_a.Ready()) { Debug(&quot;Session A still ready...&quot;); } else { Debug(&quot;Session A NO LONGER ready...&quot;);}<br>
&gt;                            if (leg_b.Ready()) { Debug(&quot;Session B still ready...&quot;); } else { Debug(&quot;Session B NO LONGER ready...&quot;);}<br>
&gt;                        }<br>
&gt;                        else<br>
&gt;                        {<br>
&gt;                            Debug(&quot;A-Leg aborted while dialing...&quot;);<br>
&gt;                        }<br>
&gt;<br>
&gt;                        if (leg_b.Ready())<br>
&gt;                        {<br>
&gt;                            Debug(&quot;B-Leg still here, so hanging up B-Leg...&quot;);<br>
&gt;                            leg_b.Hangup(&quot;NORMAL_CALL_CLEARING&quot;);<br>
&gt;                            leg_b.destroy();<br>
&gt;                        }<br>
&gt;                    }<br>
&gt;                    else<br>
&gt;                    {<br>
&gt;                        string obCause = leg_b.hangupCause();<br>
&gt;<br>
&gt;                        leg_a.HangUp(obCause);<br>
&gt;                        Debug(&quot;Route failed with: &quot;+obCause);<br>
&gt;                    }<br>
&gt;                    return true;<br>
&gt;<br>
&gt; Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at &quot;// ****** BRIDGE SHOULD BE HERE ****** &quot; like this:<br>
&gt;<br>
&gt; leg_a.sleep(1000, 0);<br>
&gt; string apiResult = fsApi.ExecuteString(string.Format(&quot;uuid_bridge {1} {0}&quot;, leg_a.GetUuid(), leg_b.GetUuid()));<br>
&gt; Debug(&quot;apiResult=&quot;+apiResult);<br>
&gt;<br>
&gt; The console log shows &quot;+OK {guid of leg_a}<br>
&gt;<br>
&gt; but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge.<br>
&gt; I have checked without bridge to check if codecs are the the same and they both are PCMU 8000.<br>
&gt; Please any help is appreciated! I have been trying to make this work for over a week now, but it won&#39;&#39;t work.<br>
&gt;<br>
&gt; note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...<br>
&gt;<br>
&gt; Best Regards,<br>
&gt;<br>
&gt; Mike.<br>
&gt;<br>
&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>&lt;mailto:<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>&gt;<br>
&gt; <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
&gt; <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt; <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-dev mailing list<br>
&gt; <a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a>&lt;mailto:<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a>&gt;<br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt; !DSPAM:4f07185e32767836217473!<br>
&gt;<br>
&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
&gt; <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt; <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-dev mailing list<br>
&gt; <a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br>