|
@@ -460,117 +460,9 @@ exit;
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 强制下麦
|
|
|
- */
|
|
|
- public function updateSiteInfo() {
|
|
|
- $user_id = $this->request->request("user_id");// 用户ID
|
|
|
- if(!$user_id) $this->error("参数缺失!");
|
|
|
-
|
|
|
- // 更新用户在线状态为离线
|
|
|
- \app\common\model\User::update(["is_online"=>0],["id"=>$user_id]);
|
|
|
-// \app\common\model\User::update(["is_live"=>0],["id"=>$user_id]);
|
|
|
- \app\common\model\Party::update(["is_online"=>0],["user_id"=>$user_id]);
|
|
|
-
|
|
|
- // 获取用户所在群信息
|
|
|
- $groupids = $this->getJoindGroupList($user_id);
|
|
|
-
|
|
|
- if($groupids["ErrorCode"] == 0) {
|
|
|
- $grouplist = $groupids["GroupIdList"];
|
|
|
- $groupsites = [];
|
|
|
- if($grouplist) foreach($grouplist as $k => $v) {
|
|
|
- // 获取群组消息
|
|
|
- $groupInfo = $this->getGroupInfo($v["GroupId"]);
|
|
|
-
|
|
|
- if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
|
|
|
-
|
|
|
- // 踢出用户在线组
|
|
|
- RedisUtil::getInstance('online',$v["GroupId"])->HDel($user_id);
|
|
|
- }
|
|
|
- // 强制下麦
|
|
|
- $this->downSite($user_id,$groupsites);
|
|
|
- }
|
|
|
-
|
|
|
- $this->success("状态更新成功!");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新麦位前四
|
|
|
- */
|
|
|
- public function updatePosition($user_id,$party_id) {
|
|
|
- // 获取用户头像
|
|
|
- $userInfo = \app\common\model\User::field("avatar")->where(["id"=>$user_id])->find();
|
|
|
- $userAvatar = isset($userInfo["avatar"])?$userInfo["avatar"]:"";
|
|
|
-
|
|
|
- $redisData = RedisUtil::getInstance('party',$party_id)->get();
|
|
|
- if(!$redisData) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- $partyInfo = json_decode($redisData,true);
|
|
|
-
|
|
|
- // 遍历已有头像
|
|
|
- $partyuser = isset($partyInfo["party_user"])?$partyInfo["party_user"]:"";
|
|
|
- if(is_array($partyuser)) foreach($partyuser as $k => $v) if($v === $userAvatar) unset($partyInfo["party_user"][$k]);
|
|
|
-
|
|
|
- RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- /**
|
|
|
- * 取消排麦
|
|
|
- */
|
|
|
- public function cancelLineUp($user_id,$party_id) {
|
|
|
- if (!$party_id || !$user_id) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $data=unserialize(RedisUtil::getInstance('party_lineup')->hGet($party_id));
|
|
|
- // 更改红点排麦数量
|
|
|
- $num = 0;
|
|
|
- $send = false;
|
|
|
- if($data) foreach($data as $k => $v) {
|
|
|
- if($v["user_id"] == $user_id) {
|
|
|
- $send = true;
|
|
|
- unset($data[$k]);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- RedisUtil::getInstance('party_lineup')->hSet($party_id,serialize($data));
|
|
|
-
|
|
|
- if($send) {
|
|
|
- is_array($data) && $num = count($data);
|
|
|
-
|
|
|
- $random = rand(10000000,99999999);
|
|
|
- $usersig = $this->usersig("administrator");
|
|
|
- // 获取配置信息
|
|
|
- $config = config("tencent_im");
|
|
|
- $url = "https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg";
|
|
|
- $url .= "?sdkappid=".$config["sdkappid"];
|
|
|
- $url .= "&identifier=administrator";
|
|
|
- $url .= "&usersig=".$usersig;
|
|
|
- $url .= "&random=".$random;
|
|
|
- $url .= "&contenttype=json";
|
|
|
- $tencentObj = new tencentim($url);
|
|
|
|
|
|
- $data = [];
|
|
|
- $data["GroupId"] = $party_id;
|
|
|
- $data["Random"] = rand(1000000,9999999);
|
|
|
- $message = [
|
|
|
- "message" => json_encode(["type"=>23,"content"=>$num]),
|
|
|
- "version" => "1.0",
|
|
|
- "action" => 301,
|
|
|
- "command" => ""
|
|
|
- ];
|
|
|
- $data["MsgBody"][] = [
|
|
|
- "MsgType" => "TIMCustomElem",
|
|
|
- "MsgContent" => [
|
|
|
- "Data"=> json_encode($message)
|
|
|
- ],
|
|
|
- ];
|
|
|
- $tencentObj->toSend($data);
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
|
|
|
//trtc_callback,直播callback
|
|
|
//https://cloud.tencent.com/document/product/647/51586#eventId
|
|
@@ -661,28 +553,7 @@ exit;
|
|
|
// 记录在线用户在房间情况
|
|
|
RedisUtil::getInstance('livingUser')->hSet($userId,$roomId);
|
|
|
|
|
|
- // 更新房间在线状态
|
|
|
- $partyInfo = $redis->get("party_" . $roomId);
|
|
|
- if ($partyInfo) {
|
|
|
- $partyInfo = json_decode($partyInfo, true);
|
|
|
- if ($partyInfo["is_online"] != 1) {
|
|
|
- $partyInfo["is_online"] = 1;
|
|
|
- $redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 更新房间在线状态
|
|
|
- $liveInfo = $redis->get("livebc_" . $roomId);
|
|
|
- if ($liveInfo) {
|
|
|
- $liveInfo = json_decode($liveInfo, true);
|
|
|
- if ($input['EventInfo']['Role'] == 20) {
|
|
|
- $liveInfo["is_online"] = 1;
|
|
|
- $redis->set("livebc_" . $roomId, json_encode($liveInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
- $rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>1]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
}elseif($input['EventType'] == 104){
|
|
|
//退出房间,主播role=20 观众role=21
|
|
@@ -692,28 +563,7 @@ exit;
|
|
|
// 扣除在线用户在房间情况
|
|
|
RedisUtil::getInstance('livingUser')->hDel($userId);
|
|
|
|
|
|
- // 更新房间在线状态
|
|
|
- $partyInfo = RedisUtil::getInstance('party',$roomId)->get();
|
|
|
- if ($partyInfo) {
|
|
|
- $partyInfo = json_decode($partyInfo, true);
|
|
|
- $memCount = count(RedisUtil::getInstance('online',$roomId)->hGetAll());
|
|
|
- if ($memCount <= 0) {
|
|
|
- $partyInfo["is_online"] = 0;
|
|
|
- RedisUtil::getInstance('party',$roomId)->set(json_encode($partyInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
- }
|
|
|
- }
|
|
|
- //
|
|
|
- $liveInfo = RedisUtil::getInstance('livebc',$roomId)->get();
|
|
|
- if ($liveInfo) {
|
|
|
- $liveInfo = json_decode($liveInfo, true);
|
|
|
- if($input['EventInfo']['Role'] == 20){
|
|
|
- $liveInfo["is_online"] = 0;
|
|
|
- RedisUtil::getInstance('livebc',$roomId)->set(json_encode($liveInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
- $rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>0]);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}elseif($input['EventGroupId'] == 2){
|
|
@@ -738,12 +588,12 @@ exit;
|
|
|
case 'State.StateChange': // 用户在线状态变更
|
|
|
$info = $input["Info"];
|
|
|
if($info["Action"] == "Login") { // 用户登录
|
|
|
- $loginToday = Db::name('user')->where('id',$info["To_Account"])->whereTime('onlinetime', 'today')->find();
|
|
|
+ /*$loginToday = Db::name('user')->where('id',$info["To_Account"])->whereTime('onlinetime', 'today')->find();
|
|
|
if ($loginToday){
|
|
|
\app\common\model\User::update(["is_online"=>1,"onlinetime"=>time()],["id"=>$info["To_Account"]]);
|
|
|
}else{
|
|
|
\app\common\model\User::update(["is_online"=>1,"onlinetime"=>time()],["id"=>$info["To_Account"]]);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
$res = [];
|
|
|
$res["ActionStatus"] = "OK";
|
|
@@ -752,73 +602,20 @@ exit;
|
|
|
echo json_encode($res);exit;
|
|
|
} elseif($info["Action"] == "Logout" || $info["Action"] == "Disconnect") { // 用户退出 不需要管什么原因
|
|
|
// 更新用户在线状态为离线
|
|
|
- $updateData['is_online'] = 0;
|
|
|
- $user = Db::name('user')->where('id',$info["To_Account"])->find();
|
|
|
- if (!empty($user)) {
|
|
|
- // 客户觉得实时判断导致在线用户数量过少,此处,不再根据IM处理用户在线状态,已在API父类中做接口访问频率处理用户在线状态
|
|
|
- // if ($user['gender'] == 1) {
|
|
|
- // $updateData['is_active'] = 0;
|
|
|
- // }
|
|
|
- }
|
|
|
- \app\common\model\User::update($updateData,["id"=>$info["To_Account"]]);
|
|
|
+// $updateData['is_online'] = 0;
|
|
|
+// $user = Db::name('user')->where('id',$info["To_Account"])->find();
|
|
|
+// if (!empty($user)) {
|
|
|
+// // 客户觉得实时判断导致在线用户数量过少,此处,不再根据IM处理用户在线状态,已在API父类中做接口访问频率处理用户在线状态
|
|
|
+// // if ($user['gender'] == 1) {
|
|
|
+// // $updateData['is_active'] = 0;
|
|
|
+// // }
|
|
|
+// }
|
|
|
+// \app\common\model\User::update($updateData,["id"=>$info["To_Account"]]);
|
|
|
//\app\common\model\User::update(["is_live"=>0],["id"=>$info["To_Account"]]);
|
|
|
|
|
|
- // 获取用户在派对直播间情况信息
|
|
|
- $livingUserPartyId = RedisUtil::getInstance('livingUser')->hGet($info["To_Account"]);
|
|
|
- if ($livingUserPartyId) {
|
|
|
- // 扣除在线用户在房间情况
|
|
|
- RedisUtil::getInstance('livingUser')->hDel( $info["To_Account"]);
|
|
|
- RedisUtil::getInstance('online',$livingUserPartyId)->HDel($info["To_Account"]);
|
|
|
- }
|
|
|
|
|
|
- // 获取用户所在群信息
|
|
|
- $groupids = $this->getJoindGroupList($info["To_Account"]);
|
|
|
-// \app\common\model\Test::update(["content"=>json_encode($groupids)],["id"=>1]);
|
|
|
- if($groupids["ErrorCode"] == 0) {
|
|
|
- $grouplist = $groupids["GroupIdList"];
|
|
|
- $groupsites = [];
|
|
|
- if($grouplist) foreach($grouplist as $k => $v) {
|
|
|
- // 获取群组消息
|
|
|
- $groupInfo = $this->getGroupInfo($v["GroupId"]);
|
|
|
-
|
|
|
- if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
|
|
|
-
|
|
|
- // 踢出用户在线组
|
|
|
- RedisUtil::getInstance('online',$v["GroupId"])->HDel($info["To_Account"]);
|
|
|
-
|
|
|
- // 更新麦位前四
|
|
|
- $this->updatePosition($info["To_Account"],$v["GroupId"]);
|
|
|
-
|
|
|
- // 取消排麦
|
|
|
- $this->cancelLineup($info["To_Account"],$v["GroupId"]);
|
|
|
-
|
|
|
- // 房间状态变更
|
|
|
- $partyInfo = RedisUtil::getInstance('party',$v["GroupId"])->get();
|
|
|
- if($partyInfo) {
|
|
|
- $partyInfo = json_decode($partyInfo,true);
|
|
|
- $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
|
|
|
- if($memCount <= 0) {
|
|
|
- $partyInfo["is_online"] = 0;
|
|
|
- RedisUtil::getInstance('party',$v["GroupId"])->set(json_encode($partyInfo));
|
|
|
- \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $liveInfo = RedisUtil::getInstance('live',$v["GroupId"])->get();
|
|
|
- if($liveInfo) {
|
|
|
- $liveInfo = json_decode($liveInfo,true);
|
|
|
- $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
|
|
|
- if($memCount <= 0) {
|
|
|
- $liveInfo["is_online"] = 0;
|
|
|
- RedisUtil::getInstance('live',$v["GroupId"])->set(json_encode($liveInfo));
|
|
|
- \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 强制下麦
|
|
|
- print_r($this->downSite($info["To_Account"],$groupsites));
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
break;
|