Clio/Server/ClientsManager.pm

filter: Statementstmt 52.9% 18 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 100% 3 / 3 totaltotal 54.1% 26 / 48 CC 2 SCAR 8.3
CC
2
Cov
50%
new_client
6.0
__ANON__
2.0
disconnect_client
2.0
CRAP 2.3
« Clio/Server/TCP.pm ↑ Summary Clio/Server/TCP/Client/Handle.pm »
1  
2 package Clio::Server::ClientsManager;
3 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 $Clio::Server::ClientsManager::AUTHORITY = 'cpan:AJGB';
5 }
6 {
7 4 $Clio::Server::ClientsManager::VERSION = '0.02';
8 }
9 # ABSTRACT: Clients manager
10  
11 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Class::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 with 'Clio::Role::HasContext';
17  
18  
19 has 'clients' => (
20 is => 'ro',
21 lazy => 1,
22 0 ▶ default => sub { +{} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 4 );
24  
25  
26 0 ▶sub new_client {
Subroutine new_client: not called CC=2 SCAR=17.9
Pod documented
27 0 my ($self, %args) = @_;
28  
29 0 my $uuid = delete $args{id};
30  
31 0 ▶ if ( my $client = $self->clients->{ $uuid } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $client = $self->clients->{$uuid}) 0 0 0
32 0 return $client->_restore( %args );
33 }
34  
35 0 my $client_class = $self->c->config->server_client_class;
36 0 $self->c->log->trace("Creating new client, class of $client_class");
37 0 Class::Load::load_class($client_class);
38  
39 0 return $self->clients->{ $uuid } = $client_class->new(
40 manager => $self,
41 id => $uuid,
42 %args
43 );
44 }
45  
46  
47 0 ▶sub disconnect_client {
Subroutine disconnect_client: not called CC=1 SCAR=6.9
Pod documented
48 0 my ($self, $client_id) = @_;
49  
50 0 $self->c->log->debug("Disconnecting client $client_id");
51  
52 0 $self->clients->{ $client_id }->disconnect;
53  
54 0 delete $self->clients->{ $client_id };
55 }
56  
57  
58 0 ▶sub total_count {
Subroutine total_count: not called CC=1 SCAR=6.9
Pod documented
59 0 my $self = shift;
60  
61 0 return scalar keys %{ $self->clients };
62 }
63  
64 4 1;
65  
66  
67 __END__
« Clio/Server/TCP.pm ↑ Summary Clio/Server/TCP/Client/Handle.pm »