[asterisk-users] Time-limited calls -- revisited

A J Stiles asterisk_list at earthshod.co.uk
Wed Aug 24 04:15:53 CDT 2011


I have got time-limited calls with a warning announcement working now .....  
almost.  Something is going slightly wrong, because the call file that gets 
created to trigger the announcement is persisting even after both ends of the 
call have hung up.

When a code is dialled, the user enters the context "time-limited-call".  An 
announcement is played and the user then dials the number they want to speak 
to.  The macro "set-1-min-warning" creates a future-timestamped call file 
which then uses the "whisper" functionality of ChanSpy() to cause an 
announcement to be heard in the phone which originated the call.

Now, I have to admit, this bit I cribbed from somewhere else.  As far as I 
understand it, a call is set up between extensions "s" and "pbk" in the one-
minute-warning context, which aren't actually attached to any physical phones; 
but extension "pbk"  (for playback)  starts spying on, and whispering to, 
${WARNED_PARTY} -- which variable is set within the call file -- and so that 
extension hears the announcement in the soundfile "ajs-1-minute-warning", 
which gets played to the extension "pbk" when it answers.


I do get the warning being played correctly at 1 minute  (I can hear it but 
the called party can't),  and the call disconnects once its 2 minutes are up.  
But then the call file is not going away even after both parties have hung up 
their phones.


I have enclosed relevant snippets from my extensions.conf below.  Sound files 
are named an such a way as it should be obvious what they do.  The ${ANALOGUE} 
prefix dials out over the POTS via my TDM410P.

(I just spotted I hardcoded the warning to play after 1 minute rather than 
determining it from ARG1.  And I guess also I ought to remove unneeded "one 
minute warning" call files in a h extension too.  But for now, I'm more 
concerned with call files persisting unnecessarily)


[time-limited-call]

exten => s,1,NoOp(Getting ready for time-limited call)
exten => s,n,Set(chan=${CUT(CHANNEL(name),-,1)})
exten => s,n,NoOp(Channel name is ${chan})
exten => s,n,Background(ajs-dial-now)
exten => s,n,WaitExten(5)
exten => s,n,Goto(1)

exten => _0XXX.,Macro(set-1-min-warning,${chan},119)
exten => _0XXX.,n,Dial(${ANALOGUE}/${EXTEN},180)
exten => _0XXX.,n,Playback(ss-noservice)
exten => _0XXX.,n,Hangup


[one-minute-warning]

exten => s,1,Answer()
exten => s,n,Dial(Local/pbk at four-minute-warning,30,A(ajs-1-min-warning))
exten => s,n,Hangup()

exten => pbk,1,Answer()
exten => pbk,n,ChanSpy(${WARNED_PARTY},qsW)
exten => pbk,n,Hangup()


[macro-set-1-min-warning]

exten => s,1,NoOp(Getting ready to create a callfile for timed warning on 
channel ${ARG1})
exten => s,n,Set(now=${STRFTIME(${EPOCH},,%Y%m%d%H%M.%S)})
exten => s,n,Set(warn_time=${STRFTIME($[${EPOCH} + 60],,%Y%m%d%H%M.%S)})
exten => s,n,NoOp(Right now the time is ${now})
exten => s,n,NoOp(Warning will sound at ${warn_time})
exten => s,n,System(echo -e "Channel:Local/s at one-minute-warning\nContext:one-
minute-warning\nSetVar: __WARNED_PARTY=${ARG1}\nExtension:pbk" > 
/tmp/warn_${warn_time})
exten => s,n,System(touch -t ${warn_time} /tmp/warn_${warn_time})
exten => s,n,System(mv /tmp/warn_${warn_time} /var/spool/asterisk/outgoing/)
exten => s,n,Set(TIMEOUT(absolute)=119)


-- 
AJS

Answers come *after* questions.



More information about the asterisk-users mailing list