| 1 | package SockJS::Transport::XHRPolling; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base 'SockJS::Transport::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 3 | my $self = shift->SUPER::new(@_); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | push @{$self->{allowed_methods}}, 'POST'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | return $self; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | sub dispatch_POST { | ||||||||||||||||||||||||||
|
Subroutine
dispatch_POST: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | 3 | my ($env, $conn) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 21 | 3 | my $respond = shift; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | if ($conn->is_connected && !$conn->is_reconnecting) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$conn->is_connected and not $conn->is_reconnecting
MC/DC50%1/2
$conn->is_connected and not $conn->is_reconnecting
$conn->is_connected
not $conn->is_reconnecting
Truth table66%2/3
A and not(B)
A= $conn->is_connectedB= not $conn->is_reconnecting
| |||||||||||||||||||||||||||||
| 24 | 1 | $self->_write($env, $respond, | |||||||||||||||||||||||||||
| 25 | 'c[2010,"Another connection still open"]'); | ||||||||||||||||||||||||||||
| 26 | 1 | return; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | $conn->write_cb( | ||||||||||||||||||||||||||||
| 30 | 2 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 2 | my $conn = shift; | |||||||||||||||||||||||||||
| 32 | 2 | my ($message) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | $self->_write($env, $respond, $message); | |||||||||||||||||||||||||||
| 35 | 2 | $conn->reconnecting; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 2 | ); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | if ($conn->is_closed) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 40 | 1 | $conn->connected; | |||||||||||||||||||||||||||
| 41 | 1 | $conn->close; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | elsif ($conn->is_connected) { | ||||||||||||||||||||||||||||
| 44 | 0 | $conn->reconnected; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||
| 47 | 1 | $conn->write('o'); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1 | $conn->connected; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 3 | }; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 3 | ▶ | sub _write { | ||||||||||||||||||||||||||
|
Subroutine
_write: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 3 | my ($env, $respond, $message) = @_; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 3 | $message .= "\n"; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 3 | $respond->( | |||||||||||||||||||||||||||
| 61 | [ | ||||||||||||||||||||||||||||
| 62 | 200, [ 'Content-Type' => 'application/javascript; charset=UTF-8', ], | ||||||||||||||||||||||||||||
| 63 | [$message] | ||||||||||||||||||||||||||||
| 64 | ] | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | 1; | |||||||||||||||||||||||||||