line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::MessagePack; |
2
|
5
|
|
|
5
|
|
135085
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
160
|
|
3
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
135
|
|
4
|
5
|
|
|
5
|
|
118
|
use 5.010001; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
258
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
6008
|
use AnyEvent::Handle; |
|
5
|
|
|
|
|
108871
|
|
|
5
|
|
|
|
|
239
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
5774
|
use Data::MessagePack 0.34; |
|
5
|
|
|
|
|
7116
|
|
|
5
|
|
|
|
|
164
|
|
10
|
5
|
|
|
5
|
|
4467
|
use Data::MessagePack::Stream 0.05; |
|
5
|
|
|
|
|
2647
|
|
|
5
|
|
|
|
|
1081
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
AnyEvent::Handle::register_write_type(msgpack => sub { |
13
|
|
|
|
|
|
|
my ($self, $data) = @_; |
14
|
|
|
|
|
|
|
Data::MessagePack->pack($data); |
15
|
|
|
|
|
|
|
}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
AnyEvent::Handle::register_read_type(msgpack => sub { |
18
|
|
|
|
|
|
|
my ($self, $cb) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# FIXME This implementation eats all the data, so the stream may |
21
|
|
|
|
|
|
|
# contain only MessagePack packets. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $unpacker = $self->{_msgpack} ||= Data::MessagePack::Stream::->new; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub { |
26
|
|
|
|
|
|
|
my $buffer = delete $_[0]{rbuf}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$unpacker->feed($buffer) if defined $buffer; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if ($unpacker->next) { |
31
|
|
|
|
|
|
|
$cb->( $_[0], $unpacker->data ); |
32
|
|
|
|
|
|
|
return 1; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
}); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |