line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2010-2011 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Net::Async::Tangence::Server; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
626982
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
157
|
|
9
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
118
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
3172
|
use IO::Async::Listener '0.36'; |
|
4
|
|
|
|
|
6670
|
|
|
4
|
|
|
|
|
112
|
|
12
|
4
|
|
|
4
|
|
26
|
use base qw( IO::Async::Listener ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
326
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
255
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
1653
|
use Net::Async::Tangence::ServerProtocol; |
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
1225
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
C - serve C clients using C |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This subclass of L accepts L client |
27
|
|
|
|
|
|
|
connections. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 PARAMETERS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
The following named parameters may be passed to C or C: |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over 8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item registry => Tangence::Registry |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The L for the server's objects. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=back |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _init |
46
|
|
|
|
|
|
|
{ |
47
|
3
|
|
|
3
|
|
56000
|
my $self = shift; |
48
|
3
|
|
|
|
|
8
|
my ( $params ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$params->{handle_constructor} = sub { |
51
|
4
|
|
|
4
|
|
10
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return Net::Async::Tangence::ServerProtocol->new( |
54
|
|
|
|
|
|
|
registry => $self->{registry}, |
55
|
|
|
|
|
|
|
on_closed => $self->_capture_weakself( sub { |
56
|
2
|
|
|
|
|
20
|
my $self = shift; |
57
|
2
|
|
|
|
|
22
|
$self->remove_child( $_[0] ); |
58
|
4
|
|
|
|
|
61
|
} ), |
59
|
|
|
|
|
|
|
); |
60
|
3
|
|
|
|
|
21
|
}; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
27
|
$self->SUPER::_init( $params ); |
63
|
|
|
|
|
|
|
|
64
|
3
|
50
|
|
|
|
94
|
$self->{registry} = delete $params->{registry} if exists $params->{registry}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub on_accept |
68
|
|
|
|
|
|
|
{ |
69
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
70
|
4
|
|
|
|
|
8
|
my ( $conn ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
37
|
$self->add_child( $conn ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Useful for testing |
76
|
|
|
|
|
|
|
sub make_new_connection |
77
|
|
|
|
|
|
|
{ |
78
|
4
|
|
|
4
|
0
|
3370
|
my $self = shift; |
79
|
4
|
|
|
|
|
10
|
my ( $sock ) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Mass cheating |
82
|
4
|
|
|
|
|
42
|
my $conn = $self->{handle_constructor}->( $self ); |
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
401
|
$conn->configure( handle => $sock ); |
85
|
4
|
|
|
|
|
705
|
$self->on_accept( $conn ); |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
980
|
return $conn; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Paul Evans |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
0x55AA; |