Files
yusheng-php/application/api/controller/Xintiao.php

37 lines
815 B
PHP
Raw Normal View History

2025-10-20 10:02:41 +08:00
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Log;
use app\common\controller\BaseCom;
class Xintiao extends BaseCom
{
2025-12-02 19:08:07 +08:00
//房间内保持心跳
public function keep_room_heartbeat()
2025-10-20 10:02:41 +08:00
{
2025-12-02 19:08:07 +08:00
$room_id = input('room_id');
2025-10-20 10:02:41 +08:00
$user_id = $this->uid;
2025-12-02 19:08:07 +08:00
$is_xintiao = db::name('vs_room_heartbeat')->where(['user_id' => $user_id, 'room_id' => $room_id])->find();
2025-10-20 10:02:41 +08:00
if($is_xintiao){
2025-12-02 19:28:24 +08:00
db::name('vs_room_heartbeat')->where('id' , $is_xintiao['id'])->update(['updatetime' => time()]);
2025-10-20 10:02:41 +08:00
}else{
2025-12-02 19:08:07 +08:00
db::name('vs_room_heartbeat')->insert([
2025-10-20 10:02:41 +08:00
'user_id' => $user_id,
'createtime' => time(),
'updatetime' => time()
2025-12-02 19:08:07 +08:00
]);
2025-10-20 10:02:41 +08:00
}
2025-12-02 14:30:43 +08:00
return V(1, '成功', null);
2025-10-20 10:02:41 +08:00
}
}