MrGamoo/Kibitz/Server.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 3 SCAR 18.4
CC
3
Cov
0%
handler
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.3
1 # -*- perl -*-
2  
3 # Copyright (c) 2010 AdCopy
4 # Author: Jeff Weisberg
5 # Created: 2010-Jan-22 14:20 (EST)
6 # Function:
7 #
8 # $Id: Server.pm,v 1.1 2010/11/01 18:41:59 jaw Exp $
9  
10 package AC::MrGamoo::Kibitz::Server;
11 use AC::MrGamoo::Debug 'kibitz_server';
12 use AC::MrGamoo::Protocol;
13 use strict;
14  
15 require "AC/protobuf/mrgamoo_status.pl";
16  
17 sub handler {
18 my $class = shift;
19 my $io = shift;
20 my $proto = shift;
21 my $req = shift;
22 my $content = shift;
23  
24 debug("recvd request");
25 if( $req ){
26 AC::MrGamoo::Kibitz::Peers->update_sceptical( $req->{myself} );
27 }
28  
29 unless( $proto->{want_reply} ){
30 $io->shut();
31 return;
32 }
33  
34 # respond with all known peers
35 my $all = AC::MrGamoo::Kibitz::Peers->peer_list_all();
36 my $resp = AC::MrGamoo::Protocol->encode_reply( $proto, {
37 status => $all,
38 } );
39  
40 debug("sending status reply");
41 $io->write_and_shut( $resp );
42 }
43  
44 1;