Commit bbabc57d authored by zhuwei's avatar zhuwei

算法优化,环信接口有限制,每个时间段最多能推送多少请求

parent 4f034e1a
...@@ -142,6 +142,7 @@ class ChatService ...@@ -142,6 +142,7 @@ class ChatService
{ {
//todo //todo
$this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from); $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush(); $rPush = new RPush();
......
...@@ -28,7 +28,19 @@ class RPush ...@@ -28,7 +28,19 @@ class RPush
*/ */
public function send($target_type, $target, $msg_content, $from, $type, $access_token, $callback) public function send($target_type, $target, $msg_content, $from, $type, $access_token, $callback)
{ {
//todo 这里做算法优化,环信接口有限制,每个时间段最多能推送多少请求 //todo
if(Cache::get('save_message_num')){
$save_message_num=Cache::get('save_message_num');
if($save_message_num>10){
sleep(1);
Cache::set('save_message_num', 0);
}else{
$save_message_num=$save_message_num+1;
Cache::set('save_message_num', $save_message_num);
}
}else{
Cache::set('save_message_num', 0);
}
$response = $this->sendRequestByCurl($target_type, $target, $msg_content, $from, $type, $access_token); $response = $this->sendRequestByCurl($target_type, $target, $msg_content, $from, $type, $access_token);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment