Webqq/Client/Remote/_recv_message.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 6 SCAR 37.4
CC
6
Cov
0%
Mojo::Webqq::Client::_recv_message
42.0
CRAP 42.0
1 sub Mojo::Webqq::Client::_recv_message{
2 my $self = shift;
3 return if $self->is_stop;
4 return if $self->is_polling;
5 $self->is_polling(1);
6 my $api_url = ($self->security?'https':'http') . '://d1.web2.qq.com/channel/poll2';
7 my $callback = sub {
8 my ($json,$ua,$tx) = @_;
9 eval{
10 #分析接收到的消息,并把分析后的消息放到接收消息队列中
11 if(defined $json){
12 $self->parse_receive_msg($json);
13 $self->emit(receive_raw_message=>$tx->res->body,$json);
14 }
15 };
16 $self->error($@) if $@;
17 $self->is_polling(0);
18 #重新开始接收消息
19 $self->emit("poll_over");
20 };
21  
22 my %r = (
23 ptwebqq => $self->ptwebqq,
24 clientid => $self->clientid,
25 psessionid => $self->psessionid,
26 key => "",
27 );
28 my $headers = {Referer=>"http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2",json=>1};
29 my $id = $self->http_post(
30 $api_url,
31 $headers,
32 form=>{r=>$self->to_json(\%r)},
33 $callback
34 );
35 $self->poll_connection_id($id);
36 }
37 1;