[Freeswitch-users] Problems with setinputCallback

Dinesh Kapoor dineshkapoor27 at gmail.com
Mon Jan 23 17:30:20 MSK 2012


Hello,

   I have a functionality that I am trying to implement via Freeswitch and
mod_python, in which a user calls in, Freeswitch hangs up the call and then
call the user back. All should happen from inside Freeswitch. Here is the
code that I had written for it:

def handler(session, args):

 if is_callback_set(app_instance):
            schedule_callback(app_instance, session.getCallerID())

is_callback_set(app_instance) : checks if we need to callback on this
application instance. schedule_callback(app_instance,
session.getCallerID()) : function to call the caller back

inside schedule_callback, I create a new thread called CallerbackThread,
and start the callback in another thread.

Inside CallBackThread, following happens:

def run(self):

                new_session = Session(url)

                if new_session.answered():

                    new_session.ai = self.app_instance
                    new_session.getCallerID = lambda:
new_session.getVariable("destination_number")

                    new_session.setInputCallback(call_back)
                    new_session.isHungup = lambda: new_session.getState()
== 'CS_HANGUP'

                    while not new_session.isHungup():
                        new_session.streamFile("abcd.mp3")

                    new_session.hangup()

def call_back(session,what,obj):

    logger.debug("hi callback")


The originate occurs and I am able to hear the file getting streamed
correctly. But when I press any dtmf input, then on first input nothing
happens, and in the next input I start getting "TypeError : call_back
expects 3 args, 0 given" error. I dont know what can be the solution. Any
help regarding this is highly appreciated!

Regards,
Dinesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120123/a94b02e2/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list