Net::S...eChain(3pm)

πŸ’– Net::S...eChain(3pm) πŸ’–

okay bestie, so this page comes from the User Contributed Perl Documentation, and the title it's filed under is Net::S...eChain(3pm) (yes it's abbreviated like that, the full vibe is Net::SIP::ReceiveChain, iykyk). Buckle up, we're doing packet handling πŸ’…


✨ NAME ✨

Net::SIP::ReceiveChain β€” handle incoming packet by multiple receivers 🫢


🌸 SYNOPSIS 🌸

# create proxy which works as a registrar too, but
# all register requests should be authorized

my $registrar = Net::SIP::Registrar->new...
my $auth = Net::SIP::Authorize->new ....
my $reg_chain = Net::SIP::ReceiveChain->new(
      [ $auth,$registrar ],
      methods => [ 'REGISTER' ],
);

my $proxy = Net::SIP::StatelessProxy->new...
my $chain = Net::SIP::ReceiveChain->new(
      [ $registrar,$proxy ]
);

like… look at her go ✨ a whole authorizing chain in six lines, no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

So this package's whole job is handling incoming packets by multiple receivers. The classic example: make sure that requests headed for Net::SIP::Registrar get authorized first by Net::SIP::Authorize. Chain them up, and the first one that wants the packet takes it πŸŽ€

The objects hanging out in your chain can literally be:

  • Net::SIP::Registrar
  • Net::SIP::StatelessProxy
  • Net::SIP::Authorize
  • Net::SIP::ReceiveChain itself (yes, chains in chains, iconic πŸ’…)
  • …and every other object which handles receive like described below πŸ’–

πŸ‘‘ CONSTRUCTOR πŸ‘‘

new ( OBJECTS, %ARGS )

This creates a new registar object (their spelling, not mine, we respect the source πŸ™ˆ). OBJECTS is a reference to an array of objects implementing the receive method.

%ARGS can have the following keys:

  • filter β€” a callback which gets called during receive with all arguments of the method. If it returns TRUE the packet will be handled by the chain, otherwise not.
  • methods β€” if filter is not given but methods is, it will set filter to a callback which accepts only the methods specified in the array reference given to methods. bestie that's just a filter with extra steps and we love that for her πŸ’…

πŸ’… METHODS πŸ’…

receive ( PACKET,LEG,FROM )

  • PACKET is the incoming packet πŸ“¦
  • LEG is the Net::SIP::Leg where the packet arrived 🦡
  • FROM is the ip:port of the sender πŸ“

Responses will be send back to the sender through the same leg. 🫢

Called from the managing Net::SIP::Dispatcher object if a new packet arrives.

Returns TRUE if the packet was fully handled by one of the objects in the chain, else FALSE:

  1. If a filter was given, checks the packet against the filter and returns FALSE if the filter does return FALSE.
  2. Otherwise it will call receive on all objects in the chain until one of these returns TRUE. In this case it will return TRUE.
  3. If no object in the chain handled the packet it will return FALSE.
no cap: FALSE means "nobody claimed this one, it's not mine", so don't go assuming it got handled. 🫠

and that's the whole page, bestie, we ate and left no crumbs βœ¨πŸ’–

This one's from perl v5.40.1, dated 2025-12-07, filed as Net::S...eChain(3pm). mwah πŸ’‹ go handle some packets πŸŽ€

πŸ“¦ where this page comes from