mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 16:58:35 +00:00
Dispatch will call you on register, and call you back if you hangup on next register
This commit is contained in:
parent
8ce6198bf9
commit
bf093e9dc1
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
use ESL::Dispatch;
|
use ESL::Dispatch;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $daemon = init ESL::Dispatch({});
|
my $daemon = init ESL::Dispatch({});
|
||||||
|
my $calls;
|
||||||
|
# Debug Yo!
|
||||||
|
#ESL::eslSetLogLevel(7);
|
||||||
|
|
||||||
$| = 1;
|
$| = 1;
|
||||||
|
|
||||||
@ -11,23 +15,34 @@ sub worker {
|
|||||||
print "I'm a worker\n";
|
print "I'm a worker\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub heartbeat {
|
sub register {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $event = shift;
|
my $event = shift;
|
||||||
print Dumper $event;
|
my $esl = $self->{_esl};
|
||||||
|
my $contact = $event->{contact};
|
||||||
|
my $profile = $event->{'profile-name'};
|
||||||
|
my $callid = $event->{'call-id'};
|
||||||
|
|
||||||
|
return if $call->{$callid};
|
||||||
|
|
||||||
|
$contact =~ s/.*\<(.*)\>.*/{my_call_id=$callid}sofia\/$profile\/$1/;
|
||||||
|
$esl->api('bgapi', "originate $contact &echo");
|
||||||
|
print "Adding $callid to calls hash\n";
|
||||||
|
$call->{$callid} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub channel_hangup {
|
sub channel_hangup {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $event = shift;
|
my $event = shift;
|
||||||
print Dumper $event;
|
my $callid = $event->{variable_my_call_id};
|
||||||
print "DO SQL GOODIES HERE!\n";
|
print "Removing $callid from calls hash\n";
|
||||||
|
delete $call->{$callid};
|
||||||
}
|
}
|
||||||
|
|
||||||
$0 = "ESL::Dispatch rocks!";
|
$0 = "ESL::Dispatch rocks!";
|
||||||
|
|
||||||
$daemon->set_worker(\&worker, 2000);
|
$daemon->set_worker(\&worker, 2000);
|
||||||
$daemon->set_callback("heartbeat", \&heartbeat);
|
$daemon->set_callback("custom", \®ister, 'sofia::register');
|
||||||
$daemon->set_callback("channel_hangup", \&channel_hangup);
|
$daemon->set_callback("channel_hangup", \&channel_hangup);
|
||||||
|
|
||||||
$daemon->run;
|
$daemon->run;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user