[Freeswitch-users] mod_python post-processing after hangup

Novak Joe joes.mailing.lists at gmail.com
Wed Sep 10 22:26:15 PDT 2008


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.")
-----------------------------
-----------------------------




More information about the FreeSWITCH-users mailing list