41 lines
934 B
PHP
41 lines
934 B
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use think\Controller;
|
|
use think\Db;
|
|
use think\Log;
|
|
|
|
use app\common\controller\BaseCom;
|
|
|
|
class Xintiao extends BaseCom
|
|
{
|
|
|
|
//房间内保持心跳
|
|
public function keep_room_heartbeat()
|
|
{
|
|
$room_id = input('room_id');
|
|
if(!$room_id){
|
|
return V(0, '参数错误', null);
|
|
}
|
|
$user_id = $this->uid;
|
|
$is_xintiao = db::name('vs_room_heartbeat')->where(['user_id' => $user_id, 'room_id' => $room_id])->find();
|
|
if($is_xintiao){
|
|
db::name('vs_room_heartbeat')->where('id' , $is_xintiao['id'])->update(['updatetime' => time()]);
|
|
}else{
|
|
db::name('vs_room_heartbeat')->insert([
|
|
'user_id' => $user_id,
|
|
'room_id' => $room_id,
|
|
'createtime' => time(),
|
|
'updatetime' => time()
|
|
]);
|
|
}
|
|
return V(1, '成功', null);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |