File Coverage

blib/lib/Net/WebSocket/EVx.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 8 75.0
condition 1 3 33.3
subroutine 9 9 100.0
pod 2 2 100.0
total 47 51 92.1


line stmt bran cond sub pod time code
1             # ABSTRACT: Perl wrapper around Wslay websocket library
2             package Net::WebSocket::EVx;
3 1     1   105197 use strict; use warnings;
  1     1   1  
  1         25  
  1         4  
  1         1  
  1         48  
4 1     1   4 use EV ();
  1         1  
  1         9  
5 1     1   2 use XSLoader ();
  1         2  
  1         37  
6             our $VERSION;
7             BEGIN {
8 1     1   2 $VERSION = '0.20';
9 1         554 XSLoader::load(__PACKAGE__, $VERSION);
10             }
11 1     1   6 use constant { WS_FRAGMENTED_EOF => 0, WS_FRAGMENTED_ERROR => -1, WS_FRAGMENTED_DATA => 1, WS_RSV1_BIT => 0x04 };
  1         1  
  1         100  
12 1     1   5 use Exporter 'import';
  1         1  
  1         190  
13             our @EXPORT = qw/WS_FRAGMENTED_EOF WS_FRAGMENTED_ERROR WS_FRAGMENTED_DATA WS_RSV1_BIT/;
14              
15             sub new {
16 12     12 1 969471 my (undef, $self) = @_;
17 12 100       32 $self->{buffering} = 1 unless defined $self->{buffering};
18 12 100       26 $self->{type} = 'server' unless defined $self->{type};
19             _wslay_event_context_init(
20             $self,
21             (defined($self->{fd}) && $self->{fd} || fileno($self->{fh})),
22 12   33     258 int($self->{type} eq 'server')
23             );
24 12         28 _wslay_event_config_set_no_buffering($self, int(!$self->{buffering}));
25 12 50       26 _wslay_event_config_set_max_recv_msg_length($self, $self->{max_recv_size}) if defined $self->{max_recv_size};
26 12         41 bless $self
27             }
28              
29 1 50   1 1 20 sub wait { if ($_[1]) { $_[0]->_set_waiter($_[1]) } }
  1         48  
30              
31             1;