File: ReceiveChain.pod

package info (click to toggle)
libnet-sip-perl 0.46-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 720 kB
  • ctags: 328
  • sloc: perl: 7,312; makefile: 2
file content (98 lines) | stat: -rw-r--r-- 2,311 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

=head1 NAME

Net::SIP::ReceiveChain - handle incoming packet by multiple receivers

=head1 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 ]
  );

=head1 DESCRIPTION

This package is used to handle incoming packets by multiple receivers,
e.g. make sure that requests for L<Net::SIP::Registrar> will be 
authorized by L<Net::SIP::Authorize>.

Objects in the chain might be L<Net::SIP::Registrar>, L<Net::SIP::StatelessProxy>,
L<Net::SIP::Authorize>, L<Net::SIP::ReceiveChain> itself and
every other object which handles C<receive> like described below.

=head1 CONSTRUCTOR

=over 4

=item new ( OBJECTS, %ARGS )

This creates a new registar object, OBJECTS is a reference to an array of
objects implementing the C<receive> method.

%ARGS can have the following keys:

=over 8

=item filter

A callback which gets called during C<receive> with all arguments of
the method. If it returns TRUE the packet will be handled by the 
chain, otherwise not.

=item methods

If B<filter> is not given but B<methods> is it will set B<filter>
to a callback which accepts only the methods specified in the 
array reference given to B<methods>.

=back

=back

=head1 METHODS

=over 4

=item receive ( PACKET,LEG,FROM )

PACKET is the incoming packet,
LEG is the L<Net::SIP::Leg> where the packet arrived and FROM
is the C<< "ip:port" >> of the sender. Responses will be send
back to the sender through the same leg.

Called from the managing L<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:

=over 8

=item *

If a filter was given checks the packet against the filter and
returns FALSE if the filter does return FALSE.

=item *

Otherwise it will call C<receive> on all objects in the
chain until one of these returns TRUE. In this case it
will return TRUE.

=item *

If no object in the chain handled the packet it will return FALSE.

=back

=back