line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sprocket::Local::Connection; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
130
|
|
4
|
5
|
|
|
5
|
|
26
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
186
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
24
|
use Sprocket qw( Connection ); |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
33
|
|
7
|
5
|
|
|
5
|
|
25
|
use base qw( Sprocket::Connection ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
388
|
|
8
|
5
|
|
|
5
|
|
29
|
use POE::Filter::Stream; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
121
|
|
9
|
5
|
|
|
5
|
|
27
|
use POE::Filter::Stackable; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
2432
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
14
|
0
|
|
|
|
|
|
$class->SUPER::new( |
15
|
|
|
|
|
|
|
local_ip => '127.0.0.1', |
16
|
|
|
|
|
|
|
local_port => 0, |
17
|
|
|
|
|
|
|
peer_ip => '127.0.0.1', |
18
|
|
|
|
|
|
|
peer_hostname => '127.0.0.1', |
19
|
|
|
|
|
|
|
peer_port => 0, |
20
|
|
|
|
|
|
|
peer_addr => "127.0.0.1:0", |
21
|
|
|
|
|
|
|
_filter => POE::Filter::Stackable->new( |
22
|
|
|
|
|
|
|
Filters => [ |
23
|
|
|
|
|
|
|
POE::Filter::Stream->new(), |
24
|
|
|
|
|
|
|
] |
25
|
|
|
|
|
|
|
), |
26
|
|
|
|
|
|
|
__buffer => [], |
27
|
|
|
|
|
|
|
@_ |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
*filter_out = *filter_in = *filter; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub filter { |
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
return $self->{_filter}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
*write = *send; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# TODO use the filter!! |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub send { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ( ref $self->{__callback} ) { |
|
|
0
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->{__callback}->( @_ ); |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} elsif ( $self->{__callback} ) { |
49
|
0
|
|
|
|
|
|
$poe_kernel->post( $self->{__callback} => @_ ); |
50
|
0
|
|
|
|
|
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
push( @{$self->{__buffer}}, @_ ); |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub attach { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $callback = shift; |
61
|
0
|
|
|
|
|
|
my $get_events = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( $callback ) { |
64
|
0
|
|
|
|
|
|
$self->{__callback} = $callback; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $arr = $self->{__buffer}; |
68
|
0
|
|
|
|
|
|
$self->{__buffer} = []; |
69
|
0
|
0
|
|
|
|
|
unless ( $get_events ) { |
70
|
0
|
0
|
|
|
|
|
if ( ref $self->{__callback} ) { |
71
|
0
|
|
|
|
|
|
foreach ( @$arr ) { |
72
|
0
|
|
|
|
|
|
$self->{__callback}->( $_ ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} else { |
75
|
0
|
|
|
|
|
|
foreach ( @$arr ) { |
76
|
0
|
|
|
|
|
|
$poe_kernel->post( $self->{__callback} => $_ ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
return @$arr ? $arr : []; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub detach { |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
my $get_events = shift; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
delete $self->{__callback}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
return unless ( $get_events ); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $arr = $self->{__buffer}; |
94
|
0
|
|
|
|
|
|
$self->{__buffer} = []; |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
return @$arr ? $arr : []; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub close { |
100
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
$self->SUPER::close(@_); |
102
|
|
|
|
|
|
|
# XXX tell connector we closed? |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |