| 1 | package Linux::Event::WebSocket::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Linux::Event::WebSocket::Client::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Linux::Event::WebSocket::Client::_HTTPConnection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Linux::Event::WebSocket::_Handshake; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Linux::Event::WebSocket::_State; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | my $DEFAULT_MAX_MESSAGE_SIZE = 16 * 1024 * 1024; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | ▶ | sub _load_connection_class ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_connection_class: called CC=6 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | croak 'new(): connection_class must be a package name' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $class or ref $class or not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $class or ref $class
MC/DC0%0/3
not defined $class or ref $class or not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
not defined $class
ref $class
not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $classB= ref $classC= not $class =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | if !defined($class) || ref($class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | || $class !~ /\A[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | ▶ | if (!$class->can('send_text')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | (my $file = "$class.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | croak 'new(): connection_class must inherit Linux::Event::WebSocket::Client::Connection' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | if !$class->isa('Linux::Event::WebSocket::Client::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | return $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 35 | ▶ | sub _take_callback ($name, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_take_callback: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 35 | ▶ | return undef if !exists $option->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 24 | my $callback = delete $option->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 24 | ▶ | croak "new(): $name must be a coderef" if ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 24 | return $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 7 | ▶ | sub _subprotocols ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_subprotocols: called CC=6 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | croak 'new(): subprotocols must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | if ref($value) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | my @copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | for my $token (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | croak 'new(): each subprotocol must be a WebSocket token' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $token or ref $token or not $token =~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
not defined $token or ref $token
MC/DC0%0/3
not defined $token or ref $token or not $token =~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
not defined $token
ref $token
not $token =~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $tokenB= ref $tokenC= not $token =~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if !defined($token) || ref($token) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | || $token !~ /\A[!#\$%&'*+\-.^_`|~0-9A-Za-z]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | push @copy, "$token"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | return \@copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | ▶ | sub _headers ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_headers: called CC=10 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 7 | ▶ | croak 'new(): headers must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | if ref($value) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | my %reserved = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | host connection upgrade sec-websocket-key sec-websocket-version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | sec-websocket-protocol sec-websocket-extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | my @copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 7 | for my $pair (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | croak 'new(): each header must be a [name, value] pair' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $pair ne "ARRAY" or @$pair != 2
MC/DC0%0/2
ref $pair ne "ARRAY" or @$pair != 2
ref $pair ne "ARRAY"
@$pair != 2
Truth table0%0/3
A or B
A= ref $pair ne "ARRAY"B= @$pair != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | if ref($pair) ne 'ARRAY' || @$pair != 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($name, $header_value) = @$pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | croak 'new(): header name and value must be scalars' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not defined $name or ref $name or not defined $header_value or ref $header_value
not defined $name or ref $name or not defined $header_value
not defined $name or ref $name
MC/DC0%0/4
not defined $name or ref $name or not defined $header_value or ref $header_value
not defined $name
ref $name
not defined $header_value
ref $header_value
Truth table0%0/5
not(A) or B or not(C) or D
A= not defined $nameB= ref $nameC= not defined $header_valueD= ref $header_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | if !defined($name) || ref($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | || !defined($header_value) || ref($header_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | croak "new(): WebSocket handshake owns header $name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if $reserved{lc $name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @copy, [ "$name", "$header_value" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | return \@copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | ▶ | sub _nonnegative_number ($where, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nonnegative_number: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | croak "$where must be a non-negative number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $value or ref $value or not "$value" =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
not defined $value or ref $value
MC/DC0%0/3
not defined $value or ref $value or not "$value" =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
not defined $value
ref $value
not "$value" =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not "$value" =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if !defined($value) || ref($value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | || "$value" !~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | return 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | ▶ | sub _positive_integer ($where, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_positive_integer: called CC=5 SCAR=21.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | ▶ | croak "$where must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/u or $value < 1
not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/u
not defined $value or ref $value
MC/DC0%0/4
not defined $value or ref $value or not "$value" =~ /\A[0-9]+\z/u or $value < 1
not defined $value
ref $value
not "$value" =~ /\A[0-9]+\z/u
$value < 1
Truth table20%1/5
not(A) or B or not(C) or D
A= not defined $valueB= ref $valueC= not "$value" =~ /\A[0-9]+\z/uD= $value < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | if !defined($value) || ref($value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | || "$value" !~ /\A[0-9]+\z/ || $value < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | return 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 7 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=19 SCAR=32.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | my $loop = delete $option{loop} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | ▶ | // croak 'new(): loop is required'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $option{"loop"} // croak("new(): loop is required")
MC/DC0%0/1
delete $option{"loop"} // croak("new(): loop is required")
delete $option{"loop"}
Truth table50%1/2
A
A= delete $option{"loop"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | croak 'new(): loop must implement add() and watch_fd()' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
builtin::blessed($loop) and $loop->can("add") and $loop->can("watch_fd")
builtin::blessed($loop) and $loop->can("add")
MC/DC0%0/3
builtin::blessed($loop) and $loop->can("add") and $loop->can("watch_fd")
builtin::blessed($loop)
$loop->can("add")
$loop->can("watch_fd")
Truth table25%1/4
A and B and C
A= builtin::blessed($loop)B= $loop->can("add")C= $loop->can("watch_fd")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | if !blessed($loop) || !$loop->can('add') || !$loop->can('watch_fd'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | my $connection_class = _load_connection_class( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | delete($option{connection_class}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | ▶ | // 'Linux::Event::WebSocket::Client::Connection', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $option{"connection_class"} // "Linux::Event::WebSocket::Client::Connection"
MC/DC0%0/1
delete $option{"connection_class"} // "Linux::Event::WebSocket::Client::Connection"
delete $option{"connection_class"}
Truth table50%1/2
A
A= delete $option{"connection_class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | my %callbacks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | for my $name (qw(on_open on_message on_close on_error on_drain)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 35 | my $callback = _take_callback($name, \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 35 | (my $short = $name) =~ s/\Aon_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 35 | ▶ | $callbacks{$short} = $callback if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | my $subprotocols = _subprotocols( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | ▶ | exists($option{subprotocols}) ? delete($option{subprotocols}) : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | my $headers = _headers( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 7 | ▶ | exists($option{headers}) ? delete($option{headers}) : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | my $origin = delete $option{origin}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 7 | ▶ | croak 'new(): origin must be a scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $origin and ref $origin
MC/DC0%0/2
defined $origin and ref $origin
defined $origin
ref $origin
Truth table33%1/3
A and B
A= defined $originB= ref $origin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | if defined($origin) && ref($origin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7 | ▶ | my $tls = exists($option{tls}) ? delete($option{tls}) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | ▶ | croak 'new(): tls must be a hash reference' if ref($tls) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | my $connect_timeout = delete $option{connect_timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 7 | ▶ | $connect_timeout = _nonnegative_number( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'new(): connect_timeout', $connect_timeout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ) if defined $connect_timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | my $close_timeout = _nonnegative_number( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 'new(): close_timeout', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 7 | ▶ | exists($option{close_timeout}) ? delete($option{close_timeout}) : 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | my $max_message_size = _positive_integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 'new(): max_message_size', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | exists($option{max_message_size}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ? delete($option{max_message_size}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | ▶ | : $DEFAULT_MAX_MESSAGE_SIZE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | my $data = delete $option{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 7 | ▶ | croak 'new(): unknown option(s): ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | loop => $loop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | connection_class => $connection_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | callbacks => \%callbacks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | subprotocols => $subprotocols, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | origin => defined($origin) ? "$origin" : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | tls => { %$tls }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | connect_timeout => $connect_timeout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | close_timeout => $close_timeout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | max_message_size => $max_message_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | connection => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | url => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | ▶ | sub _destination ($url) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_destination: called CC=20 SCAR=36.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | ▶ | croak 'connect(): URL must be a non-empty scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $url or ref $url or $url eq ""
not defined $url or ref $url
MC/DC0%0/3
not defined $url or ref $url or $url eq ""
not defined $url
ref $url
$url eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $urlB= ref $urlC= $url eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | if !defined($url) || ref($url) || $url eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7 | my ($scheme) = "$url" =~ /\A([A-Za-z][A-Za-z0-9+.-]*):/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | ▶ | $scheme = lc($scheme // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$scheme // ""
MC/DC0%0/1
$scheme // ""
$scheme
Truth table50%1/2
A
A= $scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 7 | ▶ | croak 'connect(): URL scheme must be ws or wss' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$scheme ne "ws" and $scheme ne "wss"
MC/DC0%0/2
$scheme ne "ws" and $scheme ne "wss"
$scheme ne "ws"
$scheme ne "wss"
Truth table66%2/3
A and B
A= $scheme ne "ws"B= $scheme ne "wss"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | if $scheme ne 'ws' && $scheme ne 'wss'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | my $http_url = "$url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ▶ | my $http_scheme = $scheme eq 'wss' ? 'https' : 'http'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | $http_url =~ s/\A[A-Za-z][A-Za-z0-9+.-]*:/$http_scheme:/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | my $uri = URI->new($http_url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 7 | my $host = $uri->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7 | ▶ | croak 'connect(): URL must contain a host' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $host or $host eq ""
MC/DC0%0/2
not defined $host or $host eq ""
not defined $host
$host eq ""
Truth table33%1/3
not(A) or B
A= not defined $hostB= $host eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | if !defined($host) || $host eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 7 | ▶ | croak 'connect(): URL userinfo is not supported' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $uri->userinfo and length $uri->userinfo
MC/DC0%0/2
defined $uri->userinfo and length $uri->userinfo
defined $uri->userinfo
length $uri->userinfo
Truth table33%1/3
A and B
A= defined $uri->userinfoB= length $uri->userinfo
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if defined($uri->userinfo) && length($uri->userinfo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 7 | my $port = $uri->port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | ▶ | croak 'connect(): URL port must be between 1 and 65535' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $port && $port =~ /\A[0-9]+\z/u or $port < 1 or $port > 65535
not defined $port && $port =~ /\A[0-9]+\z/u or $port < 1
defined $port && $port =~ /\A[0-9]+\z/u
MC/DC0%0/4
not defined $port && $port =~ /\A[0-9]+\z/u or $port < 1 or $port > 65535
defined $port
$port =~ /\A[0-9]+\z/u
$port < 1
$port > 65535
Truth table20%1/5
not(A && B) or C or D
A= defined $portB= $port =~ /\A[0-9]+\z/uC= $port < 1D= $port > 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | if !defined($port) || $port !~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | || $port < 1 || $port > 65_535; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | ▶ | my $default_port = $scheme eq 'wss' ? 443 : 80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | ▶ | my $authority_host = $host =~ /:/ ? "[$host]" : $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | my $host_header = $authority_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | ▶ | $host_header .= ":$port" if $port != $default_port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 7 | ▶ | scheme => $scheme, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | secure => $scheme eq 'wss' ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | port => 0 + $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | host_header => $host_header, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub _report_error ($state, $connection, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_report_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $message = "$error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $message =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if (my $callback = $state->{callbacks}{error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $callback->($connection, $message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | sub connect ($self, $url) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | croak 'connect(): Client already has an active connection' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | ▶ | if $self->{connection} && !$self->{connection}->is_closed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"connection"} and not $self->{"connection"}->is_closed
MC/DC0%0/2
$self->{"connection"} and not $self->{"connection"}->is_closed
$self->{"connection"}
not $self->{"connection"}->is_closed
Truth table33%1/3
A and not(B)
A= $self->{"connection"}B= not $self->{"connection"}->is_closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 7 | my $destination = _destination($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my ($handshake, $request) = Linux::Event::WebSocket::_Handshake->client_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | origin => $self->{origin}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | subprotocols => $self->{subprotocols}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | headers => $self->{headers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | host_header => $destination->{host_header}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | my $state = Linux::Event::WebSocket::_State->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | endpoint_type => 'client', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | callbacks => $self->{callbacks}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | subprotocols => $self->{subprotocols}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | data => $self->{data}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | handshake => $handshake, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | request => $request, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | secure => $destination->{secure}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | url => "$url", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | close_timeout => $self->{close_timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | max_message_size => $self->{max_message_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 7 | $state->{connection_class} = $self->{connection_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | my %connect = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | loop => $self->{loop}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | host => $destination->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | port => $destination->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 7 | data => $state, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | $connect{timeout} = $self->{connect_timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | if defined $self->{connect_timeout}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | ▶ | if ($destination->{secure}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | require Linux::Event::TLS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | $connect{transport} = Linux::Event::TLS->client( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | server_name => $destination->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | alpn => ['http/1.1'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | %{$self->{tls}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 7 | my $connection = Linux::Event::WebSocket::Client::_HTTPConnection->connect( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | %connect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | $self->{connection} = $connection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 7 | $self->{url} = "$url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | return $connection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub loop ($self) { $self->{loop} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub data ($self) { $self->{data} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub connection_class ($self) { $self->{connection_class} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connection_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | sub connection ($self) { $self->{connection} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub url ($self) { $self->{url} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub is_open ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_open: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $connection = $self->{connection} or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return 0 if !$connection->isa('Linux::Event::WebSocket::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return $connection->is_open; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub send_text ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_text: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | or croak 'send_text(): Client is not connected'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | croak 'send_text(): WebSocket handshake is not complete' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | if !$connection->isa('Linux::Event::WebSocket::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return $connection->send_text(@argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub send_binary ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_binary: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | or croak 'send_binary(): Client is not connected'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | croak 'send_binary(): WebSocket handshake is not complete' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | if !$connection->isa('Linux::Event::WebSocket::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $connection->send_binary(@argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub ping ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | my $connection = $self->{connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | or croak 'ping(): Client is not connected'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | croak 'ping(): WebSocket handshake is not complete' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | if !$connection->isa('Linux::Event::WebSocket::Connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $connection->ping(@argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub close ($self, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my $connection = $self->{connection} or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ($connection->isa('Linux::Event::WebSocket::Connection')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $connection->close(%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } elsif (!$connection->is_closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $connection->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||