2010-03-05 23:46:37 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use ESL::Dispatch;
|
|
|
|
use Data::Dumper;
|
|
|
|
my $daemon = init ESL::Dispatch({});
|
|
|
|
|
|
|
|
$| = 1;
|
|
|
|
|
|
|
|
sub worker {
|
|
|
|
my $self = shift;
|
|
|
|
print "I'm a worker\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub heartbeat {
|
|
|
|
my $self = shift;
|
|
|
|
my $event = $self->{event_hash};
|
|
|
|
print Dumper $event;
|
|
|
|
}
|
|
|
|
|
2010-03-05 23:57:08 +00:00
|
|
|
sub channel_hangup {
|
|
|
|
my $self = shift;
|
|
|
|
my $event = $self->{event_hash};
|
|
|
|
print "DO SQL GOODIES HERE!\n";
|
|
|
|
}
|
2010-03-05 23:46:37 +00:00
|
|
|
|
2010-03-05 23:57:08 +00:00
|
|
|
$0 = "ESL::Dispatch rocks!";
|
2010-03-05 23:46:37 +00:00
|
|
|
|
|
|
|
$daemon->set_worker(\&worker, 2000);
|
|
|
|
$daemon->set_callback("heartbeat", \&heartbeat);
|
2010-03-05 23:57:08 +00:00
|
|
|
$daemon->set_callback("channel_hangup", \&channel_hangup);
|
2010-03-05 23:46:37 +00:00
|
|
|
|
|
|
|
$daemon->run;
|