Closed ghenry closed 3 years ago
It looks like I can get to INVITEs via $ua->listen( cb_invite => ())
too, but I'd like the registrar feature as well.
I think there's a lot for my use case in this https://metacpan.org/release/SULLR/Net-SIP-0.830/source/bin/answer_machine.pl
Apart from being the registrar though...hmm.
listen
will handle INVITE, create_registrar
will handle REGISTER. If you want both it should be doable by using create_chain
with the registrar as the first element and the listener as the second.
Ah, of course! Thanks for your help.
I've gone for this:
my $ua = Net::SIP::Simple->new( leg => '192.168.100.90:5060' );
my $save_invites = sub {
my ( $from, $call ) = @_;
print Dumper $call, "\n";
return 1;
};
# https://github.com/noxxi/p5-net-sip/issues/49#issuecomment-902025333
$ua->create_chain(
[ $ua->create_registrar, $ua->listen( filter => $save_invites ) ] );
$ua->loop;
I'm not seeing anything in my print unless STDERR and STDOUT are getting eaten.
Thanks.
Seeing more now I've put Debug 1 on:
1629406816.7531 DEBUG:<1>
1629406816.8227 DEBUG:<1> Net::SIP::Registrar::receive[75]: method SUBSCRIBE addr=<sip:1001@192.168.100.90>
1629406816.8228 DEBUG:<1> Net::SIP::Registrar::receive[81]: rewrite URI sip:1001@192.168.100.90 in SUBSCRIBE to sip:1001@192.168.100.90:1401;transport=udp;registering_acc=192_168_100_90
1629406816.8229 DEBUG:<1> Net::SIP::Dispatcher::__ANON__[226]: dispatcher croaked: Can't locate object method "receive" via package "0" (perhaps you forgot to load "0"?) at /usr/local/share/perl5/5.32/Net/SIP/ReceiveChain.pm line 63.
I need to put the Objects in the chain I think.
This is OK as it returns an Object:
https://metacpan.org/dist/Net-SIP/source/lib/Net/SIP/Simple.pm#L562
so I think it's my $ua->listen in the chain.
Any ideas?
Looks like listen
does not return the necessary object for the chain. Please try the change in 6ba8f4e which should hopefully fix the problem. It is not tested though.
Thanks! Will take a look. Really appreciate you doing this.
Stupid me. I should have read your tests too. Ideal - https://github.com/noxxi/p5-net-sip/blob/6ba8f4e76382b821ea7c1b76bf18850f714fc3a0/t/02_listen_and_invite.t
But anyway, all working now! Thank you very much for your advice and quick additions.
Hi all,
I'm trying to create an open registrar (working) and have some callbacks for save some data like so, but I can get my
filter
to fire:What am I not understanding here?
Thanks.