[Freeswitch-users] Timers/DTMFs During a Call
delianSPAM
delianspam at gmail.com
Wed Aug 26 23:52:35 PDT 2009
Looks like I was wrong about using the native Python timers. Here is how
they can be used in your script:
# Imports - add these new imports
import time
import threading
# class definitions - add this new class
class Timer(threading.Thread):
def __init__(self, seconds):
self.runTime = seconds
threading.Thread.__init__(self)
def run(self):
time.sleep(self.runTime)
console_log("debug", "TIMER
********************")
# entry point - add two rows in the entry point function that is called from
freeswitch
def handler(session, args):
.
t = Timer(10)
t.start()
.
So what is now remaining is to get when the call CONNECTS and how to get
DTMFs during the call.
From: delianSPAM [mailto:delianspam at gmail.com]
Sent: Thursday, August 27, 2009 9:35 AM
To: 'freeswitch-users at lists.freeswitch.org'
Subject: RE: [Freeswitch-users] Timers/DTMFs During a Call
Hello Michael!
Thank you for your reply! I know about sched_api and I use Python as a
scripting language. Also "sched_api" can be used inside python, using
session.execute. However the problem is that the "sched_api" 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.
Best Regards, Delian Tashev
P.S. Dear enlightened people, thank you for providing help to the community
by replying to the list e-mails.
From: Michael Collins [mailto:msc at freeswitch.org]
Sent: Wednesday, August 26, 2009 11:28 PM
To: freeswitch-users at lists.freeswitch.org
Subject: Re: [Freeswitch-users] Timers/DTMFs During a Call
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 & flexibility at the cost of
some resources.
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.
-MC
On Wed, Aug 26, 2009 at 7:59 AM, delianSPAM <delianspam at gmail.com> wrote:
Hello Everybody!
1. Scenario.
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).
When the call is CONNECTED, I want to:
- Receive DTMFs
- Have a timer that can call a certain function in my script. The
script will have to play a message to party A.
- Have a timer that can call a certain function in my script. The
script will have to drop the call.
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.
2. Problem.
I will be happy to receive help on:
- Which methods should I look for to implement this.
3. Details
Here is how I connect the call currently:
session.execute("bridge","sofia/internal/" + destination_number +
"@domain.com")
I have tried to create a timer callback function "my_method()" using:
ivr_timer =threading.Timer(30,my_method)
This never called the function "my_method()".
Maybe I am wrong in using threading.Timer and the "bridge" application?
Maybe I need to create a new thread and a new timer using the API of
freeswitch, plus to use the "session.setInputCallback", plus use a
conference rather than a bridge? Can you please provide any suggestions or
examples?
Thank you!
Best Regards, Delian Tashev
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090827/9bd5076e/attachment-0002.html
More information about the FreeSWITCH-users
mailing list