| 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::ServerProtocol; | ||||||||||||
| 7 | |||||||||||||
| 8 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 4 | ▶ | use base qw( Net::Async::Tangence::Protocol Tangence::Server ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 4 | ▶ | use mro 'c3'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 4 | our $VERSION = '0.14'; | |||||||||||
| 15 | |||||||||||||
| 16 | 4 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | =head1 NAME | ||||||||||||
| 19 | |||||||||||||
| 20 | C<Net::Async::Tangence::ServerProtocol> - C<Net::Async::Tangence::Protocol> | ||||||||||||
| 21 | subclass for servers | ||||||||||||
| 22 | |||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||
| 24 | |||||||||||||
| 25 | This subclass of L<Net::Async::Tangence::Protocol> provides additional logic | ||||||||||||
| 26 | required by the server side of a connection. It is not intended to be directly | ||||||||||||
| 27 | used by server implementations. | ||||||||||||
| 28 | |||||||||||||
| 29 | =cut | ||||||||||||
| 30 | |||||||||||||
| 31 | sub _init | ||||||||||||
| 32 | { | ||||||||||||
| 33 | 4 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
_init: called CC=2 SCAR=7.0
| |||||||||||||
| 34 | 4 | my ( $params ) = @_; | |||||||||||
| 35 | |||||||||||||
| 36 | 4 | $self->registry( delete $params->{registry} ); | |||||||||||
| 37 | |||||||||||||
| 38 | 4 | ▶ | $params->{on_closed} ||= undef; | ||||||||||
|
Condition50%1/2
$params->{"on_closed"} ||= undef
MC/DC0%0/1
$params->{"on_closed"} ||= undef
$params->{"on_closed"}
Truth table50%1/2
A
A= $params->{"on_closed"}
| |||||||||||||
| 39 | |||||||||||||
| 40 | 4 | $self->SUPER::_init( $params ); | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | sub configure | ||||||||||||
| 44 | { | ||||||||||||
| 45 | 8 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
configure: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 46 | 8 | my %params = @_; | |||||||||||
| 47 | |||||||||||||
| 48 | 8 | ▶ | if( exists $params{on_closed} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 4 | my $on_closed = $params{on_closed}; | |||||||||||
| 50 | $params{on_closed} = sub { | ||||||||||||
| 51 | 2 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||
| 52 | |||||||||||||
| 53 | 2 | ▶ | $on_closed->( $self ) if $on_closed; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | 4 | }; | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 8 | $self->SUPER::configure( %params ); | |||||||||||
| 58 | } | ||||||||||||
| 59 | |||||||||||||
| 60 | =head1 AUTHOR | ||||||||||||
| 61 | |||||||||||||
| 62 | Paul Evans <leonerd@leonerd.org.uk> | ||||||||||||
| 63 | |||||||||||||
| 64 | =cut | ||||||||||||
| 65 | |||||||||||||
| 66 | 4 | 0x55AA; | |||||||||||