diff --git a/perl/NGCP/Rtpengine.pm b/perl/NGCP/Rtpengine.pm index c6ce33c28..b4d55dbed 100644 --- a/perl/NGCP/Rtpengine.pm +++ b/perl/NGCP/Rtpengine.pm @@ -10,6 +10,10 @@ use Bencode; use Data::Dumper; use JSON; + +our $req_cb; + + sub new { my ($class, $addr, $port) = @_; @@ -33,6 +37,9 @@ sub req { my $cookie = rand() . ' '; my $p = $cookie . ($self->{json} ? encode_json($packet) : Bencode::bencode($packet)); $self->{socket}->send($p, 0) or die $!; + if ($req_cb) { + $req_cb->(); + } my $ret; $self->{socket}->recv($ret, 65535) or die $!; $ret =~ s/^\Q$cookie\E//s or die $ret; diff --git a/perl/NGCP/Rtpengine/AutoTest.pm b/perl/NGCP/Rtpengine/AutoTest.pm index a404f5e4b..4b8a1b5e1 100644 --- a/perl/NGCP/Rtpengine/AutoTest.pm +++ b/perl/NGCP/Rtpengine/AutoTest.pm @@ -15,6 +15,7 @@ use Exporter; our @ISA; our @EXPORT; +our $launch_cb; BEGIN { require Exporter; @@ -75,6 +76,10 @@ sub autotest_init { $tag_iter = 0; $tag_suffix = '-' . rand(); + if ($launch_cb) { + $launch_cb->(); + } + my $r = $c->req({command => 'ping'}); ok $r->{result} eq 'pong', 'ping works, daemon operational';