File Coverage

blib/lib/Mojo/Weixin/Client/Remote/_synccheck.pm
Criterion Covered Total %
statement 0 20 0.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 0 2 0.0
pod n/a
total 0 29 0.0


line stmt bran cond sub pod time code
1             sub Mojo::Weixin::_synccheck{
2 0     0     my $self = shift;
3 0 0 0       if($self->_sync_running or $self->_synccheck_running){
4             #$self->_synccheck_running(0);
5 0           $self->emit("synccheck_over",undef,undef,1);
6 0           $self->debug("消息处理程序进行中,避免重复运行(1)");
7 0           return;
8             }
9 0           $self->debug("检查消息(" . $self->_synccheck_interval . ")...");
10 0           $self->_synccheck_running(1);
11 0           my $api = "https://webpush.". $self->domain . "/cgi-bin/mmwebwx-bin/synccheck";
12             my $callback = sub {
13 0     0     my $data = shift;
14             #window.synccheck={retcode:"0",selector:"0"}
15 0           $self->_synccheck_running(0);
16 0 0         if(defined $data){
17 0           my($retcode,$selector) = $data=~/window\.synccheck=\{retcode:"([^"]+)",selector:"([^"]+)"\}/g;
18 0           $self->emit("synccheck_over",$retcode,$selector,1);
19             }
20             else{
21 0           $self->emit("synccheck_over",undef,undef,0);
22             }
23 0           };
24             my @query_string = (
25             r => $self->now(),
26             skey => $self->skey,
27             sid => $self->wxsid,
28             uin => $self->wxuin,
29             deviceid => $self->deviceid,
30 0           synckey => join("|",map {$_->{Key} . "_" . $_->{Val};} @{$self->synccheck_key->{List}}),
  0            
  0            
31             _ => $self->now(),
32             );
33 0           my $id = $self->http_get($self->gen_url2($api,@query_string),{Referer=>"https://" .$self->domain . "/"},$callback);
34 0           $self->_synccheck_connection_id($id);
35             }
36             1;