You can use POE for geting AMI events.

I'm sending you a simple poe.pl file in attachment, where you will get all raw 
events, and some callbacks are implemented for particular events. 
For your case you can add few callback like "conference join event", conference 
leave event.


Muhammad Faheem




________________________________
 From: Pat Collins <[email protected]>
To: 'Asterisk Users Mailing List - Non-Commercial Discussion' 
<[email protected]> 
Sent: Saturday, May 4, 2013 8:07 PM
Subject: [asterisk-users] AMI help needed
 


Hello group,
I put together a simple PHP based conferencing manager for Asterisk 11.3
I used ODBC MYSQL for conference IDs and PINs.  All this is working as desired 
but I would love to add an active conferences display to the front end.
It seems to me that AMI is the way to go but I have no idea how to accomplish 
this or even where to begin.
Any guidance is appreciated.
Pat...
 
 
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
              http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users
#!/usr/bin/perl -w

use strict; 
use threads;
use threads::shared;
use warnings; 
use Data::Dumper; 
use Config::Abstract::Ini; 
use POE qw(Component::Client::Asterisk::Manager);

#my $conf = '/root/poe/db_config.ini';

#AMI-POE
my $host = 'localhost'; 
my $port = '5038'; 
my $user = 'events';
my $pass = 't3chv01p3r'; 

my $debug = 0; 
my @threadz;

POE::Component::Client::Asterisk::Manager->new(
	Alias => 'monitor',
	RemoteHost	=> $host,
	RemotePort	=> $port,
	Username	=> $user,
	Password	=> $pass,
	CallBacks	=> {
		#on_event => ':all', # catchall for all manager events
		#on_dial		=> {'Event' => 'Dial'},
		on_Bridge	=> {'Event' => 'Bridge','Bridgestate' => 'Link'},
		#on_new_channel	=> { 'Event' => 'Newchannel', },
		#on_peer_status	=> { 'Event' => 'PeerStatus', },
		#on_new_callerid	=> { 'Event' => 'Newcallerid', },
		#on_ring => { 'Event' => 'Newchannel', 'State' => 'Ring', },
		on_hangup	=> { 'Event' => 'Hangup','Cause-txt' => 'Normal Clearing', },
		#on_cdr => { 'Event' => 'Cdr', },
	},
	inline_states => {
		#on_event	=> \&on_event,
		#on_newexten	=> \&on_newexten,
		#on_dial		=> \&on_dial,
		on_Bridge	=> \&on_Bridge,
		#on_answer	=> \&on_answer,
		#on_new_channel	=> \&on_new_channel,
		#on_peer_status	=> \&on_peer_status,
		#on_new_callerid	=> \&on_new_callerid,
		#on_ring => \&on_ring,
		on_hangup	=> \&on_hangup,
		#on_cdr => \&on_cdr,
	},
); POE::Kernel->run();

sub on_answer{
        print "We are in ON-Answer STATE \n";

}



sub on_Bridge{
        my $input = $_[ARG0];
	#print "on Bridge CALLER ID\n";
        print Data::Dumper->Dump([$input]);	
}

sub on_dial{
	print "on_dial\n";
}

sub on_event{
	my $input = $_[ARG0];
	# good for figuring out what manager events look like
	print Data::Dumper->Dump([$input]);
	#print "on_event\n";
}

sub on_newexten{
        my $input = $_[ARG0];
        # good for figuring out what manager events look like
        print Data::Dumper->Dump([$input]);
	my $fu_callerid = $input->{'CallerIDNum'};
	my $ext_status = $input->{'Application'};
	if($ext_status eq 'Answer'){
		print Data::Dumper->Dump([$input]);
		#my $context = '';
		#my $local_ext = '';
		#my $priority = '';
		my $channel = $input->{'Channel'};
		my $context = $input->{'Context'};
		my $local_ext = $input->{'Extension'};
		my $priority = $input->{'Priority'};	
		print "here in Answer state, $channel, $context, $local_ext, $priority \n";
	}
        #print "on_newexten\n";

}


sub on_new_channel{
        my $input = $_[ARG0];
        print "New Channel created\n";

}

sub on_peer_status{
}

sub on_new_callerid{
	print "on_new_callerid\n";
        my $input = $_[ARG0];
        my @Dial_Event=Data::Dumper->Dump([$input]);
        my $callerid = $input->{'CallerIDNum'};
        print "on_new_callerid: $callerid \n";


}




sub on_ring{

}



sub on_hangup{
        my $input = $_[ARG0];
        # good for figuring out what manager events look like
        print Data::Dumper->Dump([$input]);
	my $fu_callerid = $input->{'ConnectedLineNum'};
	my $cause_text = $input->{'Cause-txt'};
	my $channel  = $input->{'Channel'};
		
	my $tmp0 = substr($channel,0,3);
	print "leg detection...$tmp0\n";

	}
	

}


sub on_cdr{

}


--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to