Webqq/Client/Method/_recv_message.pm

filter: Statementstmt 12.9% 4 / 31 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod n/a totaltotal 9.8% 5 / 51 CC 9 SCAR 35.8
CC
9
Cov
9%
_recv_message
56.0
__ANON__
12.0
__ANON__
2.0
CRAP 35.9
« Webqq/Client/Plugin/PostImgVerifycode.pm ↑ Summary Webqq/Client/Method/_get_vfwebqq.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 0 ▶sub Webqq::Client::_recv_message{
Subroutine _recv_message: not called CC=7 SCAR=40.3
3 0 my $self = shift;
4 0 ▶ return if $self->{is_stop};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_stop"} 0 0 0
5 0 my $ua = $self->{asyn_ua};
6 0 ▶ my $api_url = ($self->{qq_param}{is_https}?'https':'http') . '://d.web2.qq.com/channel/poll2';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'qq_param'}{'is_https'} ? : 0 0 0
7 0 ▶ my $callback = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
8 0 my $response = shift;
9 0 ▶ print $response->content() if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
10 #分析接收到的消息,并把分析后的消息放到接收消息队列中
11 0 ▶ $self->parse_receive_msg($response->content()) if $response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
if $response->is_success 0 0 0
12 #重新开始接收消息
13 0 my $rand_watcher_id = rand();
14 0 ▶ $self->{watchers}{$rand_watcher_id} = AE::timer 2,0,sub{
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 0 delete $self->{watchers}{$rand_watcher_id};
16 0 $self->_recv_message();
17 0 };
18 0 };
19  
20 my %r = (
21 clientid => $self->{qq_param}{clientid},
22 psessionid => $self->{qq_param}{psessionid},
23 0 key => "",
24 );
25 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
26 0 $r{key} = 0;
27 0 $r{ids} = [];
28 }
29 0 my $post_content = [
30 r => JSON->new->utf8->encode(\%r),
31 ];
32 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
33 push @$post_content,(
34 clientid => $self->{qq_param}{clientid},
35 psessionid => $self->{qq_param}{psessionid}
36 0 );
37 }
38 0 ▶ if($self->{debug}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
39 0 require URI;
40 0 my $uri = URI->new('http:');
41 0 $uri->query_form($post_content);
42 0 print $api_url,"\n";
43 0 print $uri->query(),"\n";
44 }
45  
46 0 ▶ my @headers = $self->{type} eq 'webqq'? (Referer=>"http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3")
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
47 : (Referer=>"http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2")
48 ;
49 0 $ua->post(
50 $api_url,
51 $post_content,
52 @headers,
53 $callback
54 );
55
56 }
57 1 1;
« Webqq/Client/Plugin/PostImgVerifycode.pm ↑ Summary Webqq/Client/Method/_get_vfwebqq.pm »