| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 10 | #分析接收到的消息,并把分析后的消息放到接收消息队列中 | ||||||||||
| 11 | 0 | ▶ | $self->parse_receive_msg($response->content()) if $response->is_success; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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; | |||||||||