File: Server.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 (88 lines) | stat: -rw-r--r-- 2,561 bytes parent folder | download | duplicates (9)
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

=head1 NAME

Net::SIP::NATHelper::Server - server for Net::SIP::NATHelper::Client

=head1 DESCRIPTION

This module is a wrapper around L<Net::SIP::NATHelper::Base> and
will receive it's instructions from L<Net::SIP::NATHelper::Client>
using RPC via sockets.

=head1 CONSTRUCTOR

=over 4

=item new ( [ HELPER ], @FDS )

Will create an object which listens on all file descriptors
given in FDS for RPC from clients.

If HELPER is given and a L<Net::SIP::NATHelper::Base> object
or derived it will be used, otherwise the helper will be created.

=back

=head1 METHODS

=over 4

=item do_command ( FD )

Called when FD is available for reading.
Calls B<accept> on FD and reads the RPC packet from the
resulting file descriptor, executes it and returns result back.

Currently implemented commands are "allocate","activate" and
"close" which will map to the local methods B<allocate_sockets>,
B<activate_session> and B<close_session>.

One might redefine or add commands by changing C<< $self->{commands} >>.
The key of this hash reference is the command name and the value
is the callback.

Unknown commands will be ignored, e.g nothing returned.

=item loop

This will loop over all file descriptors it gets from B<callbacks>
in L<Net::SIP::NATHelper::Base> and the file descriptors for
the RPC sockets.

When file descriptors gets available for reading it will execute
the callbacks, e.g. forward the RTP data or call B<do_command>.
In regular intervals it will call B<expire> from L<Net::SIP::NATHelper::Base>
to expire the RTP sockets and sessions.

=item allocate_sockets ( ... )

Calls B<allocate_sockets> of the local L<Net::SIP::NATHelper::Base>
object. Takes and returns the same arguments.

=item activate_session ( ... )

Calls B<activate_session> of the local L<Net::SIP::NATHelper::Base>
object. Takes the same arguments and returns 1 if the session was
newly activated, -1 if it was activated before and false if activation failed.
Updates callbacks into the event loop.

=item close_session ( ... )

Calls B<activate_session> of the local L<Net::SIP::NATHelper::Base>
object. Takes the same arguments and returns the number of closed
sessions.
Updates callbacks into the event loop.

=item expire ( ... )

Calls B<expire> of the local L<Net::SIP::NATHelper::Base>
object. Takes the same arguments and returns the number of expired
sessions.
Updates callbacks into the event loop if necessary.

=back

=head1 BUGS

The local event loop should be pluggable, so that other implementations
could be used. Right now it's a hard coded loop using select.