[Asterisk-Users] MeetMe Features

Peter Svensson psvasterisk at psv.nu
Fri Dec 10 01:24:42 MST 2004


On Fri, 10 Dec 2004, Leif Madsen wrote:

> On Thu, 9 Dec 2004 10:59:56 +0100, Stojan Sljivic - Pamet
> <stojan.sljivic at pamet.co.yu> wrote:
> > - When someone joins the conference a message "<name> is now joining the
> > conference." is played. 
> 
> I decided to work on this today to see what happened.  I used Peter's
> logic to get me started.
> 
> This is by no means complete.  Infact, its pretty dirty, but it works
> and just wanted to post this to prove it can be done.
> 
> Now that I have the general idea of what is going on, I should be able
> to just put this entire thing right into the Perl script and not need
> any dialplan logic.  But thats why Asterisk is great, theres a 1000
> ways to accomplish your goal.

We have done all the authentication logic etc in perl. It is a lot easier, 
even more so since we have a database back end.

> This will create the family/key entry with a value of nothing.  The
> first time the user logs in it will prompt them to say their name. 
> After the user presses pound (#), it will save the file to
> /var/lib/asterisk/sounds/conf/5050/1234.wav.  You will be able to
> check to see if the user has created a wav file by doing a lookup in
> the database.

When you move to perl you can also check for the existance of the file 
directly. 

I have a few comments, in-line below:

> ; extensions.conf snippet
> ;------------------------------------------------------------------------------
> ; MeetMe Announced Join
> ; (c)2004 Leif Madsen
> ; http://www.leifmadsen.com
> ;------------------------------------------------------------------------------
> [conf-announced-join]
> exten => s,1,SetVar(pincheck=0)
> exten => s,2,Answer
> exten => s,3,Read(confnum|conf-getconfno|4)                           
>          ; get conf num

You may want to verify the room number here. It is less secure (you get 
feedback if the room is valid earlier) but a lot easier on the callers. I 
have found that callers sometimes make a mistake or a digit may be missed. 
With the above solution you only get one shot at entering the room 
number, and no feedback that it is invalid. Instead, the pin code will be 
asked for three times.

> exten => s,4,Read(confpin|conf-getpin|4)                              
>          ; get conf pin
> exten => s,5,DBGet(userannouncement=conference/room/${confnum}/${confpin})
>      ; if not available n+101
> exten => s,6,GotoIf($["${userannouncement}" =
> ""]?recordprompt,1:joinconf,1)    ; if blank, record an entry prompt
> exten => s,106,SetVar(pincheck=$[${pincheck} + 1])                    
>          ; invalid pin
> exten => s,107,GotoIf($[${pincheck} = 3]?invalidpin,1)                
>          ; if three times wrong, goto invalidpin
> exten => s,108,Playback(conf-invalidpin)
> exten => s,109,Goto(s,3)
> 
> exten => recordprompt,1,SetVar(announcement=${confpin}.wav)
> exten => recordprompt,2,DBPut(conference/room/${confnum}/${confpin}=${announcement})
> exten => recordprompt,3,Playback(after-the-tone)
> exten => recordprompt,4,Record(conf/${confnum}/${announcement}||6)
> exten => recordprompt,5,Goto(joinconf,1)
> 
> exten => joinconf,1,AGI(conference-announce.pl)
> exten => joinconf,2,MeetMe(${confnum}|q)
> 
> exten => invalidpin,1,Playback(invalid)                               
>          ; 3 times wrong
> exten => invalidpin,2,Hangup
> 
> exten => _505X,1,MeetMe(${EXTEN}|q)                                   
>          ; allow 5050 -> 5059
> exten => _505X,2,Hangup

These are used by the agi below to make the announcement, right?

> ; Perl script
> #!/usr/bin/perl
> # Announced conference join script
> # (c)2004 Leif Madsen
> # http://www.leifmadsen.com
> 
> use warnings;
> 
> use Asterisk::AGI;
> $AGI = new Asterisk::AGI;
> 
> my %input = $AGI->ReadParse();
> 
> $pin=  $AGI->get_variable('confpin');
> $conf=  $AGI->get_variable('confnum');
> 
> # callfile variables
> my $CALLFILE = "/var/lib/asterisk/agi-bin/conf-announce.call";  # this
> needs to be a temporary place before we move it to
> /var/spool/asterisk/

You need to make sure that the temporary file is stored on the same device 
as the actual spool file. Otherwise the 'mv' below will not be atomic. 
/var/spool is not unheard of to have on it's own partition. Just a heads 
up.

> my $CALL_CHANNEL = "Local/$conf\@conf-announced-join\/n";
> my $CALL_RETRIES = 1;
> my $CALL_RETRYTIME = 60;
> my $CALL_WAITTIME = 30;
> my $CALL_APP = "Playback";
> my $CALL_APP_DATA = ("conf\/$conf\/$pin");
> 
> main::Callfile();
> 
> sub main::Callfile
> {
>         open(OUTFILE, ">> $CALLFILE") or die $AGI->verbose("can't open
> $CALLFILE for writing\n");
>         print OUTFILE "Channel: $CALL_CHANNEL\n";
>         print OUTFILE "MaxRetries: $CALL_RETRIES\n";
>         print OUTFILE "RetryTime: $CALL_RETRYTIME\n";
>         print OUTFILE "WaitTime: $CALL_WAITTIME\n";
>         print OUTFILE "Application: $CALL_APP\n";
>         print OUTFILE "Data: $CALL_APP_DATA\n";
>         `mv $CALLFILE /var/spool/asterisk/outgoing`;
>         close OUTFILE;

You probably want to close first and then move to make sure the output 
buffers are flushed before the move.

Peter




More information about the asterisk-users mailing list