...
|
...
|
@@ -394,4 +394,35 @@ class LivingController extends BaseController |
|
|
|
|
|
$this->renderJson(Yii::$app->params['success_code'],'',$ret);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取在线人数
|
|
|
* @room_id 支持单个(1001) 或 多个(1001,1002)
|
|
|
*/
|
|
|
public function actionGetonlinenums()
|
|
|
{
|
|
|
try{
|
|
|
if (!$room_ids = $this->requests('room_id'))
|
|
|
{
|
|
|
$this->renderJson(Yii::$app->params['failed_code'],'缺少room_id');
|
|
|
}
|
|
|
$room_ids = explode(',',urldecode($room_ids));
|
|
|
if($room_ids){
|
|
|
$keys = $ret = [];
|
|
|
foreach ($room_ids as $k=>$room_id){
|
|
|
$keys[] = sprintf("%sonline_nums_room_%s",Yii::$app->params['cache_prefix'],$room_id);
|
|
|
}
|
|
|
|
|
|
$values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : [];
|
|
|
foreach ($values as $k=>$value){
|
|
|
$ret[$room_ids[$k]] = (int)($value ? : 0);
|
|
|
}
|
|
|
$this->renderJson(Yii::$app->params['success_code'],'',$ret);
|
|
|
}else{
|
|
|
$this->renderJson(Yii::$app->params['failed_code'],'room_id格式不正确');
|
|
|
}
|
|
|
}catch (\Exception $e){
|
|
|
$this->renderJson(Yii::$app->params['failed_code'],$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|