[Asterisk-Users] after hours - is this logic ok ?
Andrew Thompson
asteriskuser at aktzero.com
Wed Dec 31 17:56:41 MST 2003
----- Original Message -----
From: "Lance Arbuckle" <asterisk at arbuckle.org>
To: <asterisk-users at lists.digium.com>
Sent: Wednesday, December 31, 2003 1:54 PM
Subject: [Asterisk-Users] after hours - is this logic ok ?
>
> Ok, first off, Asterisk is the coolest piece of software I have EVER had
> the pleasure of using in my 8 years of running linux !! and I know I
> haven't even scratched the surface feature wise.
>
> Before I get too excited, I wanted to get all you experts to look at the
> how I implemented my after hours test. The goal is to prevent the phone
> from ringing afer certain hours, just go to VM.
>
> Bacically, when a call comes from the PSTN, I use these includes to
> either set a key in the DB or not.
>
> include => day|8:00-21:00|mon-fri|*|*
> include => day|9:00-21:00|sat-sun|*|*
> ; if we're not open, we're closed
> include => night
>
> [day]
> exten => s,2,DBput(FEATURE/DAY=yes)
> exten => s,3,Goto(s,10)
>
> [night]
> exten => s,2,NoOp
> exten => s,3,Goto(s,10)
>
>
> And then in my stdexten macro, I test for the existence of the key in
> the database. If the key exists, it must be daytime so delete the key
> and allow the calls to ring the extension. If the key does not exist,
> it must be night and since we don't want the phones to ring we jump to
> the unavailable VM. I've tested this and it works as I expect but my
> only concern is how this would hold up in a busy environment where many
> calls are being processed. Could one asterisk thread delete the
> database key before another thread had gotton the oportunity to test for
> the key ?
>
>
> [macro-stdexten]
> exten => s,1,NoOp
> < other testing crap deleted >
> exten => s,10,DBget(foo=FEATURE/DAY) ; is it day time ?
> exten => s,11,DBdel(FEATURE/DAY) ; yes, delete the key
> exten => s,12,Goto(s,201) ; and ring the phone
> exten => s,111,Goto(s,204) ; no, goto uVM
>
> exten => s,201,answer
> exten => s,202,Playback(transfer,skip)
> exten => s,203,Dial(${ARG2},5) ; Ring the interface, 20 seconds
> maximum
> exten => s,204,Voicemail(u${ARG1}) ; If unavailable, send to
> voicemail w/ unavail announce
> exten => s,205,Playback(vm-goodbye)
> exten => s,206,Wait(1)
> exten => s,207,Hangup
> exten => s,304,Voicemail(b${ARG1}) ; If busy, send to voicemail w/
> busy announce
> exten => s,305,Playback(vm-goodbye)
> exten => s,306,Wait(1)
> exten => s,307,Hangup
>
>
Although I can't provide you with an example, I think you might find it
easier to simplify the turn up/down logic.
When a call comes in, check day/night, as you already do. If it's day, set
the key. (If the key's already there, resetting it shouldn't hurt.) If it's
night, delete the key if it exists.
Then your extensions should test for the key and do the right thing if it is
or isn't there, but not touch the key themselves.
----
Andrew Thompson http://aktzero.com/
More information about the asterisk-users
mailing list