[Freeswitch-users] mod_python post-processing after hangup

Michael Collins mcollins at fcnetwork.com
Wed Sep 10 22:49:26 PDT 2008


IIRC, Anthony mentioned an elegant way of handling this not too long
ago, although it was with a different language. The gist of it was this:

While (session.is.active) {
  Do stuff
}
Do stuff after hangup

Obviously you'll need to use Python-ish syntax but you get the idea.

Alternatively you can research using the api_hangup_hook channel
variable and see if possibly this will let you do what you wish to do:
http://wiki.freeswitch.org/wiki/Channel_Variables#api_hangup_hook

in any event, please report back what you tried and if you get it to
work please add it to the more samples section of the mod_python wiki
page since that needs a little love from the Pythoners out there.

-MC


> -----Original Message-----
> From: freeswitch-users-bounces at lists.freeswitch.org
[mailto:freeswitch-
> users-bounces at lists.freeswitch.org] On Behalf Of Novak Joe
> Sent: Wednesday, September 10, 2008 10:26 PM
> To: freeswitch-users at lists.freeswitch.org
> Subject: [Freeswitch-users] mod_python post-processing after hangup
> 
> Hi,
>   I'd like to run some process after a hangup, in the background.
> 
>   I'm using mod_python and would like to run something after a call
> ends.  In the
>   snippet below I'd like the call to hangup at 'session.hangup(1)'
then
> the
>   consoleLog to print the 'Testing' message 15 seconds later.
> 
>   At present, if I hangup my call, it works, however if I stay on the
line
>   the call doesn't hangup until the call to sleep comes back.
> 
>   How can accomplish this functionality without using
> mod_event_socket, is there a way?
>   Should I stick this in the hangup_hook?  Will the hangup_hook
> maintain state for a
>   database call?
> 
>   Cheers,
>     Joe
> -----------------------------
> -----------------------------
> import os
> from freeswitch import *
> import time
> def hangup_hook(session, what):
> 	consoleLog("info","hangup hook for %s!!\n\n" % what)
> 	return
> def input_callback(session, what, obj):
> 	if (what == "dtmf"):
> 		consoleLog("info", what + " " + obj.digit + "\n")
> 	else:
> 		consoleLog("info", what + " " + obj.serialize() + "\n")
> 
> 	return "pause"
> def handler(session, args):
> 	session.answer()
> 	session.setHangupHook(hangup_hook)
> 	session.setInputCallback(input_callback)
> 	session.streamFile(session.getVariable("hold_music"))
>         session.hangup(1)
>         time.sleep(15)
>         consoleLog("info", "Testing.")
> -----------------------------
> -----------------------------
> 
> _______________________________________________
> 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




More information about the FreeSWITCH-users mailing list