line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
sub Mojo::Weixin::_sync { |
2
|
0
|
|
|
0
|
|
|
my $self = shift; |
3
|
|
|
|
|
|
|
#if($self->_synccheck_running or $self->_sync_running){ |
4
|
|
|
|
|
|
|
#if($self->_sync_running){ |
5
|
|
|
|
|
|
|
# $self->debug("消息处理程序进行中,避免重复运行(2)"); |
6
|
|
|
|
|
|
|
# return; |
7
|
|
|
|
|
|
|
#} |
8
|
0
|
|
|
|
|
|
$self->debug("接收消息..."); |
9
|
0
|
|
|
|
|
|
$self->_sync_running(1); |
10
|
0
|
|
|
|
|
|
my $api = 'https://'. $self->domain . '/cgi-bin/mmwebwx-bin/webwxsync'; |
11
|
0
|
|
|
|
|
|
my @query_string = ( |
12
|
|
|
|
|
|
|
sid => $self->wxsid, |
13
|
|
|
|
|
|
|
); |
14
|
0
|
0
|
|
|
|
|
push @query_string,(skey => $self->skey) if $self->skey; |
15
|
0
|
0
|
|
|
|
|
push @query_string,(pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket; |
16
|
0
|
|
|
|
|
|
my $post = { |
17
|
|
|
|
|
|
|
BaseRequest => {Uin => $self->wxuin,Sid=>$self->wxsid,}, |
18
|
|
|
|
|
|
|
SyncKey => $self->sync_key, |
19
|
|
|
|
|
|
|
rr => $self->now(), |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
my $callback = sub{ |
22
|
0
|
|
|
0
|
|
|
my ($json,$ua,$tx) = @_; |
23
|
0
|
|
|
|
|
|
my $status = 1; |
24
|
0
|
0
|
0
|
|
|
|
if(not defined $json){$status = 0;} |
|
0
|
0
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
elsif(defined $json and $json->{BaseResponse}{Ret} == -1){$status = 0} |
26
|
0
|
|
|
|
|
|
$self->_sync_running(0); |
27
|
0
|
|
|
|
|
|
$self->emit(receive_raw_message=>$tx->res->body,$json); |
28
|
0
|
|
|
|
|
|
$self->emit("sync_over",$json,$status); |
29
|
0
|
|
|
|
|
|
}; |
30
|
0
|
|
|
|
|
|
$self->http_post($self->gen_url($api,@query_string),{Referer=>'https://' . $self->domain . '/',json=>1},json=>$post,$callback); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
1; |