| 1 | package Sprocket::Local::Connection; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 5 | ▶ | use Sprocket qw( Connection ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 5 | ▶ | use base qw( Sprocket::Connection ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 5 | ▶ | use POE::Filter::Stream; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 5 | ▶ | use POE::Filter::Stackable; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | |||||||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 13 | 0 | 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 | 5 | *filter_out = *filter_in = *filter; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 0 | ▶ | sub filter { | ||||||||||||
|
Subroutine
filter: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||
| 35 | 0 | return $self->{_filter}; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 5 | *write = *send; | |||||||||||||
| 39 | |||||||||||||||
| 40 | # TODO use the filter!! | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | sub send { | ||||||||||||
|
Subroutine
send: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | if ( ref $self->{__callback} ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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}}, @_ ); | |||||||||||||
| 54 | |||||||||||||||
| 55 | 0 | return; | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | |||||||||||||||
| 58 | 0 | ▶ | sub attach { | ||||||||||||
|
Subroutine
attach: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||
| 59 | 0 | my $self = shift; | |||||||||||||
| 60 | 0 | my $callback = shift; | |||||||||||||
| 61 | 0 | my $get_events = shift; | |||||||||||||
| 62 | |||||||||||||||
| 63 | 0 | ▶ | if ( $callback ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 64 | 0 | $self->{__callback} = $callback; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | my $arr = $self->{__buffer}; | |||||||||||||
| 68 | 0 | $self->{__buffer} = []; | |||||||||||||
| 69 | 0 | ▶ | unless ( $get_events ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 70 | 0 | ▶ | if ( ref $self->{__callback} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | ▶ | return @$arr ? $arr : []; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 83 | } | ||||||||||||||
| 84 | |||||||||||||||
| 85 | 0 | ▶ | sub detach { | ||||||||||||
|
Subroutine
detach: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||
| 87 | 0 | my $get_events = shift; | |||||||||||||
| 88 | |||||||||||||||
| 89 | 0 | delete $self->{__callback}; | |||||||||||||
| 90 | |||||||||||||||
| 91 | 0 | ▶ | return unless ( $get_events ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 92 | |||||||||||||||
| 93 | 0 | my $arr = $self->{__buffer}; | |||||||||||||
| 94 | 0 | $self->{__buffer} = []; | |||||||||||||
| 95 | |||||||||||||||
| 96 | 0 | ▶ | return @$arr ? $arr : []; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 97 | } | ||||||||||||||
| 98 | |||||||||||||||
| 99 | 0 | ▶ | sub close { | ||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||
| 101 | 0 | $self->SUPER::close(@_); | |||||||||||||
| 102 | # XXX tell connector we closed? | ||||||||||||||
| 103 | } | ||||||||||||||
| 104 | |||||||||||||||
| 105 | 5 | 1; | |||||||||||||