[Asterisk-Users] after hours - is this logic ok ?

Lance Arbuckle asterisk at arbuckle.org
Wed Dec 31 18:16:53 MST 2003


Andrew Thompson wrote:
> 
> ----- 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/


ok, thanks for the suggestion.  I'm not sure why I decided to unset the
key from within the stdexten anyway.  I think I've been staring at this
too long :)  or maybe all the radiation from these 3 21" monitors has
finally cooked my brain cell.

So, the contexts would be more like this:

[day] 
exten => s,2,DBput(FEATURE/DAY=yes)  
exten => s,3,Goto(s,10) 

[night] 
exten => s,2,DBdel(FEATURE/DAY)     ;if we got here it must be night
time so remove the key
exten => s,3,Goto(s,10)

[macro-stdexten]
exten => s,1,NoOp
< other testing crap deleted >
exten => s,10,DBget(foo=FEATURE/DAY)    ; is it day time ?  if key
exists, goto n+1, otherwise n+101
exten => s,11,Goto(s,201)	        ; yes, well let's ring the phones
exten => s,111,Goto(s,204)              ; no, goto uVM



-- 
  .~.    Triad Internet Systems, Inc.
  /V\    Lance C. Arbuckle
 // \\   3315 Anderson Drive
/(   )\  Winston-Salem, NC 27127
 ^'~'^   336-771-2090



More information about the asterisk-users mailing list