line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tak::ConnectionService; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1065
|
use Tak::ConnectionReceiver; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
396
|
use Tak::JSONChannel; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has receiver => (is => 'ro', writer => '_set_receiver'); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has channel => (is => 'ro', writer => '_set_channel'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub BUILD { |
12
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
13
|
0
|
|
|
|
|
|
my $channel = $self->_set_channel( |
14
|
|
|
|
|
|
|
Tak::JSONChannel->new(map +($_ => $args->{$_}), qw(read_fh write_fh)) |
15
|
|
|
|
|
|
|
); |
16
|
0
|
|
|
|
|
|
my $receiver = $self->_set_receiver( |
17
|
|
|
|
|
|
|
Tak::ConnectionReceiver->new( |
18
|
|
|
|
|
|
|
channel => $channel, service => $args->{listening_service}, |
19
|
|
|
|
|
|
|
on_close => $args->{on_close}, |
20
|
|
|
|
|
|
|
) |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub start_request { |
25
|
0
|
|
|
0
|
0
|
|
my ($self, $req, @payload) = @_; |
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
|
|
|
0
|
0
|
|
my ($self, @payload) = @_; |
33
|
0
|
|
|
|
|
|
$self->channel->write_message(message => @payload); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |