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