<br><br><div class="gmail_quote">On Thu, Jan 21, 2010 at 3:35 AM, Nicolas Brenner <span dir="ltr"><<a href="mailto:nicolas@medularis.com">nicolas@medularis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="gmail_quote"><div class="im">On Wed, Jan 20, 2010 at 7:06 PM, Mike van Lammeren <span dir="ltr"><<a href="mailto:mike@van.lammeren.net" target="_blank">mike@van.lammeren.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So, I've been reading about early media in the wiki, and have made a little progress, which leads to more questions.<div><br></div><div>I understand now why a call is considered connected before one person has picked up the phone. I am also able to get my script to wait for the phone to be picked up, by setting the ignore_early_media variable when starting a new session, like this:</div>
<div><blockquote style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"><div>customerSession = freeswitch.Session("{ignore_early_media=true}sofia/gateway/<a href="http://example.com/" target="_blank">example.com/</a>" .. customerPhoneNumber)</div>
</blockquote><div><br></div><div>After that line, the script waits for the other phone to be picked up.</div><div><br></div><div>However, now I wonder what to do with calls that don't complete, get busy signals, etc.</div>
<div><br></div><div>What do people do in this case? The only related example I can find on the web is for a javascript dialer, which doesn't address any of these cases.</div></div></blockquote><div><br></div><div><br>
</div></div><div>I guess it depends on what you want to do. For example I have a lua script very similar to what you describe, although there is no confirmation involved. Depending on the hangup cause the session gets, it might try redialing with a different gateway, try again or just hangup.</div>
<div><br></div><div>Take a look here <a href="http://wiki.freeswitch.org/wiki/Hangup_causes" target="_blank">http://wiki.freeswitch.org/wiki/Hangup_causes</a> to see what each hangup cause means. You don't need to have a special case for all of them, only the ones you are interested in.</div>
<div><br></div><div>Here's an example in code which retries a call depending on the hangup cause. It retries max_retries1 times and alternates between 2 different gateways:</div><div><br></div><div><div>session1 = null;</div>
<div>max_retries1 = 3;</div><div>retries = 0;</div><div>ostr = "";</div><div>repeat </div><div> retries = retries + 1;</div><div> if (retries % 2) then ostr = originate_str1;</div><div> else ostr = originate_str12; end</div>
<div> freeswitch.consoleLog("notice", "*********** Dialing Leg1: " .. ostr .. " - Try: "..retries.." ***********\n");</div><div> session1 = freeswitch.Session(ostr);</div>
<div> local hcause = session1:hangupCause();</div><div> freeswitch.consoleLog("notice", "*********** Leg1: " .. hcause .. " - Try: "..retries.." ***********\n");</div>
<div>until not ((hcause == 'NO_ROUTE_DESTINATION' or hcause == 'RECOVERY_ON_TIMER_EXPIRE' or hcause == 'INCOMPATIBLE_DESTINATION' or hcause == 'CALL_REJECTED' or hcause == 'NORMAL_TEMPORARY_FAILURE') and (retries < max_retriesl1))</div>
</div><div><br></div><div><br></div><div>Note: originate_str1 and originate_str2 are two different dial strings for 2 different gateways.</div><div><div></div><div class="h5"><div><br></div></div></div></div></blockquote>
<div><br>Nicolas,<br><br>This is really nice. Would you be willing to add this script and a brief explanation to the wiki? You could create a whole new page and just link to it from here: <a href="http://wiki.freeswitch.org/wiki/Mod_lua#More_Samples">http://wiki.freeswitch.org/wiki/Mod_lua#More_Samples</a><br>
<br>If you have any questions please let me know!<br>-MC<br></div></div><br>