| 1 | package POE::Component::Server::JSONRPC::Tcp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use base qw(POE::Component::Server::JSONRPC); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use POE qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Component::Server::TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | Filter::Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | POE::Component::Server::JSONRPC::Tcp - POE tcp based JSON-RPC server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $self = shift->SUPER::new( @_ > 1 ? {@_} : $_[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =head2 poe_init_server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | Init TCP Server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub poe_init_server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poe_init_server: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ($self, $kernel, $session, $heap) = @_[OBJECT, KERNEL, SESSION, HEAP]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $bind = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $method = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($kernel, $tcp_session, @args) = @_[KERNEL, SESSION, ARG0..$#_ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | #~ $kernel->post( $session->ID, $method, $tcp_session->ID, @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $kernel->post( $session->ID, $method, {content=>$args[0]},$tcp_session->ID, "" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $self->{tcp} = POE::Component::Server::TCP->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Port => $self->{Port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $self->{Address} ? ( Address => $self->{Address} ) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $self->{Hostname} ? ( Hostname => $self->{Hostname} ) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $self->{Domain} ? ( Domain => $self->{Domain} ) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $self->{Concurrency} ? ( Concurrency => $self->{Concurrency} ) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ClientInput => $bind->('input_handler'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # ClientConnected => $bind->('tcp_connect_handler'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # ClientDisconnected => $bind->('tcp_disconnect_handler'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # ClientError => $bind->('tcp_client_error_handler'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # ClientFlushed => $bind->('tcp_client_flush_handler'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ClientInputFilter => $self->{ClientInputFilter} || POE::Filter::Line->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ClientOutputFilter => $self->{ClientOutputFilter} || POE::Filter::Line->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | InlineStates => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | send => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($client, $data) = @_[ARG0..$#_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $client->put($data) if $client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
$self->{'ClientInputFilter'} || 'POE::Filter::Line'->new
$self->{'ClientOutputFilter'} || 'POE::Filter::Line'->new
MC/DC0%0/2
$self->{'ClientInputFilter'} || 'POE::Filter::Line'->new
$self->{'ClientInputFilter'}
'POE::Filter::Line'->new
MC/DC0%0/2
$self->{'ClientOutputFilter'} || 'POE::Filter::Line'->new
$self->{'ClientOutputFilter'}
'POE::Filter::Line'->new
Truth table0%0/3
A || B
A= $self->{'ClientInputFilter'}B= 'POE::Filter::Line'->new
Truth table0%0/3
A || B
A= $self->{'ClientOutputFilter'}B= 'POE::Filter::Line'->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 poe_send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Send TCP response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub poe_send { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poe_send: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($kernel,$response, $content) = @_[KERNEL,ARG0..$#_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $kernel->post($response => send => $response,$content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||