| 1 | package Tak::ConnectionService; | ||
| 2 | |||
| 3 | 1 | ▶ | use Tak::ConnectionReceiver; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Tak::JSONChannel; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | has receiver => (is => 'ro', writer => '_set_receiver'); | |
| 8 | |||
| 9 | 1 | has channel => (is => 'ro', writer => '_set_channel'); | |
| 10 | |||
| 11 | sub BUILD { | ||
| 12 | 0 | ▶ | my ($self, $args) = @_; |
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 13 | my $channel = $self->_set_channel( | ||
| 14 | 0 | Tak::JSONChannel->new(map +($_ => $args->{$_}), qw(read_fh write_fh)) | |
| 15 | ); | ||
| 16 | my $receiver = $self->_set_receiver( | ||
| 17 | Tak::ConnectionReceiver->new( | ||
| 18 | channel => $channel, service => $args->{listening_service}, | ||
| 19 | on_close => $args->{on_close}, | ||
| 20 | ) | ||
| 21 | 0 | ); | |
| 22 | } | ||
| 23 | |||
| 24 | sub start_request { | ||
| 25 | 0 | ▶ | my ($self, $req, @payload) = @_; |
|
Subroutine
start_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 26 | 0 | $self->receiver->requests->{my $tag = "$req"} = $req; | |
| 27 | 0 | my $meta = { progress => !!$req->on_progress }; | |
| 28 | 0 | $self->channel->write_message(request => $tag => $meta => @payload); | |
| 29 | } | ||
| 30 | |||
| 31 | sub receive { | ||
| 32 | 0 | ▶ | my ($self, @payload) = @_; |
|
Subroutine
receive: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 33 | 0 | $self->channel->write_message(message => @payload); | |
| 34 | } | ||
| 35 | |||
| 36 | 1 | 1; | |