python - Counting duration of a freeswitch call, if greater then 10 second nobody joined then play IVR -


how count duration of call? when user join 3200 , wait 10 seconds , nobody yet joined, 3200 want play audio file.

but how count duration idea please? have tried following not working cause triggers after call hang up. need counter starts when call started.


/usr/local/freeswitch/script/wait.py

import os freeswitch import * def hangup_hook(session, what):     consolelog("info","hangup hook %s!!\n\n" % what)     return def input_callback(session, what, obj):     if (what == "dtmf"):         consolelog("info", + " " + obj.digit + "\n")     else:         consolelog("info", + " " + obj.serialize() + "\n")     return "pause"  def handler(session, args):     new_api_obj = api()     new_api_obj.executestring("pyrun postprocessing " + session.getvariable('caller_id_number'))     session.answer()     session.sethanguphook(hangup_hook)     session.setinputcallback(input_callback)     session.execute("conference", "$1-${domain_name}@ultrawideband")     session.hangup() 

/usr/local/freeswitch/script/postprocessing.py

import os, sys, time freeswitch import * def runtime(arg1):     time.sleep(10)     # there 2 person or 1 person?     # if 1 person after 10 second play      #session.streamfile("/var/tmp/ivr/sara4.wav")     # if 2 person after 10 second nothing     consolelog( "info", "caller: %s hung 10s ago!\n" % arg1 ) 

now postprocessing.py running when call end


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -