Skip to content

Commit

Permalink
去除限制
Browse files Browse the repository at this point in the history
  • Loading branch information
itzhoujun committed Dec 23, 2016
1 parent 291a3bd commit b37f80a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions push/Utils/PushMaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

class PushMaster
{
public static $last_run_time = 0; //上次开始执行时间

public static $last_run_count = 0; //上次执行条数

public static $jpush_limit = 600; // 限制每分钟600次

public static function executeIosPush(){
$item = DB::table('push')->where('platform','=','2')
Expand All @@ -39,29 +34,20 @@ public static function executeJPush(){
->where('push_type','=','1')
->where('push_brand','=','2')
->get();
$begin_time = time();
$sdk_count = 0;
$push_total_count = 0;
if(empty($data)){
return;
}
foreach ($data as $item){

$one_minute_push_count = $push_total_count+self::$last_run_count;
while($one_minute_push_count>=self::$jpush_limit && (time() - self::$last_run_time) < 60){
sleep(1);
}

$push = Push::init('jpush', $item->package_name);
$push_count = $push->exec(json_decode($item->target,true), $item->message,json_decode($item->extras,true));
if($push_count){
$sdk_count ++;
$push_total_count += $push_count;
//todo 删除
}else{
return;
}
}
self::$last_run_time = $begin_time;
self::$last_run_count = $sdk_count;
}

public static function executeAliPush(){
Expand Down

0 comments on commit b37f80a

Please sign in to comment.