Asterisk::FastAGI - Module for FastAGI handling.
use base 'Asterisk::FastAGI'; sub fastagi_handler { my $self = shift; my $param = $self->param('foo'); my $callerid = $self->input('calleridname'); $self->agi->say_number(1000); }
Asterisk::FastAGI provides a preforking daemon for handling FastAGI requests from Asterisk.
Read the Net::Server for more information about the logging facilities, configuration, etc.
First you need a module containing all of your AGI handlers.
package MyAGI; use base 'Asterisk::FastAGI'; sub agi_handler { my $self = shift; $self->agi->say_number(8675309); }
Then you simply need to have a script that runs the daemon.
#!/usr/bin/perl use MyAGI; MyAGI->run();
When it is run it creates a preforking daemon on port '4573'. That is the default port for FastAGI. Read the Net::Server documentation on how to change this and many other options.
Returns parsed parameters sent in from the AGI script.
Inside extensions.conf:
exten => 1111,1,Agi(agi://${SERVER}/fastagi_handler?foo=bar&blam=blah
You can access those parameters from inside your AGI script. Much like you would if those were URL parameters on a CGI script.
my $foo = $self->param('foo');
Returns a hash containing the input from the AGI script.
my %hash = $self->input()
If given a key. It will return that particular value.
my $uniqueid = $self->input('uniqueid');
Will return the Asterisk::AGI object.
This will process the agi request from asterisk.
Method used to dispatch the FastAGI request.
This is called by Net::Server during child initialization. This is the method to override if you are going to be creating database connections for instance.
sub child_init_hook { my $self = shift; $self->{server}{dbi} = DBI->connect(); }
Net::Server, http://asterisk.gnuinter.net/
Jason Yates <jaywhy@gmail.com>
Copyright (C) 2006-2007 by Jason Yates
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Asterisk::FastAGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Asterisk::FastAGI
CPAN shell
perl -MCPAN -e shell install Asterisk::FastAGI
For more information on module installation, please visit the detailed CPAN module installation guide.