<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=BG link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Looks like I was wrong about using the native Python timers.
Here is how they can be used in your script:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'># Imports
&#8211; add these new imports<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>import
time<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>import
threading<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>#
class definitions &#8211; add this new class<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>class
Timer(threading.Thread):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def
__init__(self, seconds):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.runTime
= seconds<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; threading.Thread.__init__(self)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def
run(self):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(self.runTime)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console_log(&quot;debug&quot;,
&quot;TIMER ********************&quot;)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>#
entry point &#8211; add two rows in the entry point function that is called from
freeswitch<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>def
handler(session, args):<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&#8230;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;t =
Timer(10)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;t.start()<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&#8230;<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>So what is now remaining is to get when the call CONNECTS and
how to get DTMFs during the call. <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> delianSPAM [mailto:delianspam@gmail.com] <br>
<b>Sent:</b> Thursday, August 27, 2009 9:35 AM<br>
<b>To:</b> 'freeswitch-users@lists.freeswitch.org'<br>
<b>Subject:</b> RE: [Freeswitch-users] Timers/DTMFs During a Call<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hello Michael!<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thank
you for your reply! I know about sched_api and I use Python as a scripting
language. Also &#8220;sched_api&#8221; can be used inside python, using session.execute.
However the problem is that the &#8220;sched_api&#8221; timer starts right after you
initiate the SETUP of the second call leg. What I need is to call something,
after a call CONNECT instead. One workaround would be if I can check what time
it took to connect the call, but I do not know/see how to do this. I do not see
a CONNECT callback function either.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Best Regards, Delian Tashev<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>P.S. Dear enlightened people, thank you for providing help to
the community by replying to the list e-mails.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> Michael Collins [mailto:msc@freeswitch.org]
<br>
<b>Sent:</b> Wednesday, August 26, 2009 11:28 PM<br>
<b>To:</b> freeswitch-users@lists.freeswitch.org<br>
<b>Subject:</b> Re: [Freeswitch-users] Timers/DTMFs During a Call<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Do you actually need Python for
the IVR, or is it that you're comfortable using a scripting lang for an IVR? I
like using XML for IVRs, but using scripting langs does give you a bit more
power &amp; flexibility at the cost of some resources.<br>
<br>
For the record, you can do this in the dialplan using XML and sched_api without
touching a scripting language. Checkout the sched_api channel variable on the
wiki - it may give you the functionality you need.<br>
<br>
-MC<o:p></o:p></p>

<div>

<p class=MsoNormal>On Wed, Aug 26, 2009 at 7:59 AM, delianSPAM &lt;<a
href="mailto:delianspam@gmail.com">delianspam@gmail.com</a>&gt; wrote:<o:p></o:p></p>

<div>

<div>

<p><span lang=EN-US>Hello Everybody!</span><o:p></o:p></p>

<p><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p style='text-indent:-18.0pt'><span lang=EN-US>1.</span><span lang=EN-US
style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
lang=EN-US>Scenario.</span><o:p></o:p></p>

<p><span lang=EN-US>I am writing an IVR in Python that gets a destination from
the calling party (party A) and then connects to the destination (party B).</span><o:p></o:p></p>

<p><span lang=EN-US>When the call is CONNECTED, I want to:</span><o:p></o:p></p>

<p style='margin-left:53.4pt;text-indent:-18.0pt'><span lang=EN-US>-</span><span
lang=EN-US style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang=EN-US>Receive DTMFs</span><o:p></o:p></p>

<p style='margin-left:53.4pt;text-indent:-18.0pt'><span lang=EN-US>-</span><span
lang=EN-US style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang=EN-US>Have a timer that can call a certain function in my
script. The script will have to play a message to party A.</span><o:p></o:p></p>

<p style='margin-left:53.4pt;text-indent:-18.0pt'><span lang=EN-US>-</span><span
lang=EN-US style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang=EN-US>Have a timer that can call a certain function in my
script. The script will have to drop the call.</span><o:p></o:p></p>

<p><span lang=EN-US>Please notice that I want to do the things after the two
parties are connected, and not after I send the Invite to party B.</span><o:p></o:p></p>

<p><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p style='text-indent:-18.0pt'><span lang=EN-US>2.</span><span lang=EN-US
style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
lang=EN-US>Problem.</span><o:p></o:p></p>

<p><span lang=EN-US>I will be happy to receive help on:</span><o:p></o:p></p>

<p style='margin-left:53.4pt;text-indent:-18.0pt'><span lang=EN-US>-</span><span
lang=EN-US style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang=EN-US>Which methods should I look for to implement this.</span><o:p></o:p></p>

<p style='margin-left:53.4pt'><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p style='text-indent:-18.0pt'><span lang=EN-US>3.</span><span lang=EN-US
style='font-size:7.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
lang=EN-US>Details</span><o:p></o:p></p>

<p><span lang=EN-US>Here is how I connect the call currently:</span><o:p></o:p></p>

<p style='text-indent:35.4pt'><span lang=EN-US>session.execute(&quot;bridge&quot;,&#8221;sofia/internal/&quot;
+ destination_number + &quot;@<a href="http://domain.com" target="_blank">domain.com</a>&#8221;)</span><o:p></o:p></p>

<p><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p><span lang=EN-US>I have tried to create a timer callback function
&#8220;my_method()&#8221; using:</span><o:p></o:p></p>

<p style='text-indent:35.4pt'><span lang=EN-US>ivr_timer
=threading.Timer(30,my_method)</span><o:p></o:p></p>

<p><span lang=EN-US>This never called the function &#8220;my_method()&#8221;.</span><o:p></o:p></p>

<p><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p><span lang=EN-US>Maybe I am wrong in using threading.Timer and the &#8220;bridge&#8221;
application? Maybe I need to create a new thread and a new timer using the API
of freeswitch, plus to use the &#8220;session.setInputCallback&#8221;, plus use a
conference rather than a bridge? Can you please provide any suggestions or
examples? </span><o:p></o:p></p>

<p><span lang=EN-US>&nbsp;</span><o:p></o:p></p>

<p><span lang=EN-US>Thank you!</span><o:p></o:p></p>

<p><span lang=EN-US>Best Regards, Delian Tashev</span><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>