File Coverage

blib/lib/Protocol/SPDY/Frame/Control/PING.pm
Criterion Covered Total %
statement 12 26 46.1
branch 0 2 0.0
condition n/a
subroutine 4 9 44.4
pod 5 5 100.0
total 21 42 50.0


line stmt bran cond sub pod time code
1             package Protocol::SPDY::Frame::Control::PING;
2             $Protocol::SPDY::Frame::Control::PING::VERSION = '1.001';
3 3     3   12 use strict;
  3         3  
  3         85  
4 3     3   10 use warnings;
  3         3  
  3         77  
5 3     3   10 use parent qw(Protocol::SPDY::Frame::Control);
  3         3  
  3         9  
6              
7             =head1 NAME
8              
9             Protocol::SPDY::Frame::Control::PING - aliveness test
10              
11             =head1 VERSION
12              
13             version 1.001
14              
15             =head1 SYNOPSIS
16              
17             =head1 DESCRIPTION
18              
19             See L and L.
20              
21             =cut
22              
23 3     3   139 use Protocol::SPDY::Constants ':all';
  3         3  
  3         862  
24              
25             =head2 type_name
26              
27             The string type for this frame ('PING').
28              
29             =cut
30              
31 0     0 1   sub type_name { 'PING' }
32              
33             =head2 id
34              
35             The unique ping ID.
36              
37             =cut
38              
39             sub id {
40 0     0 1   my $self = shift;
41 0 0         return $self->{id} unless @_;
42 0           $self->{id} = shift;
43 0           return $self;
44             }
45              
46             =head2 from_data
47              
48             Instantiate from the given data.
49              
50             =cut
51              
52             sub from_data {
53 0     0 1   my $class = shift;
54 0           my %args = @_;
55 0           my ($id) = unpack "N1", substr $args{data}, 0, 4, '';
56 0           $class->new(
57             %args,
58             id => $id,
59             );
60             }
61              
62             =head2 as_packet
63              
64             Returns the packet as a byte string.
65              
66             =cut
67              
68             sub as_packet {
69 0     0 1   my $self = shift;
70 0           my $payload = pack 'N1', $self->id;
71 0           return $self->SUPER::as_packet(
72             payload => $payload,
73             );
74             }
75              
76             =head2 to_string
77              
78             String representation, for debugging.
79              
80             =cut
81              
82             sub to_string {
83 0     0 1   my $self = shift;
84 0           $self->SUPER::to_string . ', id ' . $self->id;
85             }
86              
87             1;
88              
89             __END__