File: manager-test.pl

package info (click to toggle)
libasterisk-agi-perl 1.08-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 444 kB
  • sloc: perl: 2,883; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 962 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
#
# Example script to show how to use Asterisk::Manager
#
# Written by: James Golovich <james@gnuinter.net>
#
#

use lib './lib', '../lib';
use Asterisk::Manager;

$|++;

my $astman = new Asterisk::Manager;

$astman->user('test');
$astman->secret('test');
$astman->host('duff');

$astman->connect || die $astman->error . "\n";

$astman->setcallback('Hangup', \&hangup_callback);
$astman->setcallback('DEFAULT', \&default_callback);


#print STDERR $astman->command('zap show channels');

print STDERR $astman->sendcommand( Action => 'IAXPeers');

#print STDERR $astman->sendcommand( Action => 'Originate',
#					Channel => 'Zap/7',
#					Exten => '500',
#					Context => 'default',
#					Priority => '1' );


$astman->eventloop;

$astman->disconnect;

sub hangup_callback {
	print STDERR "hangup callback\n";
}

sub default_callback {
	my (%stuff) = @_;
	foreach (keys %stuff) {
		print STDERR "$_: ". $stuff{$_} . "\n";
	}
	print STDERR "\n";
}