|
@@ -221,68 +221,75 @@ class Easemob extends Api
|
|
|
|
|
|
//进入房间
|
|
|
if($uid && $partyid && $is_chatroom && $operation == 'in' && $error_code){
|
|
|
- $roomId = $partyid;
|
|
|
+
|
|
|
$userId = $uid;
|
|
|
|
|
|
- $this->redis->hSet("online_" . $roomId, $userId, $userId);
|
|
|
- $this->redis->zAdd("party_user_".$roomId,$userId,$userId); //新加的
|
|
|
+ $this->redis->hSet("online_" . $partyid, $userId, $userId);
|
|
|
+ $this->redis->zAdd("party_user_".$partyid,$userId,$userId); //新加的
|
|
|
// 记录在线用户在房间情况
|
|
|
- $this->redis->hSet("livingUser",$userId,$roomId);
|
|
|
+ $this->redis->hSet("livingUser",$userId,$partyid);
|
|
|
|
|
|
// 更新房间在线状态
|
|
|
- $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
+ $partyInfo = $this->redis->get("party_" . $partyid);
|
|
|
if ($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo, true);
|
|
|
if ($partyInfo["is_online"] != 1) {
|
|
|
$partyInfo["is_online"] = 1;
|
|
|
- $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
+ $this->redis->set("party_" . $partyid, json_encode($partyInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 1], ["id" => $partyid]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新房间在线状态
|
|
|
- $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
+ $liveInfo = $this->redis->get("live_" . $partyid);
|
|
|
if ($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo, true);
|
|
|
if ($liveInfo["is_online"] != 1) {
|
|
|
$liveInfo["is_online"] = 1;
|
|
|
- $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
+ $this->redis->set("live_" . $partyid, json_encode($liveInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 1], ["id" => $partyid]);
|
|
|
$rs_user = Db::name('user')->where('id',$userId)->update(['is_live'=>1]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //[环信] 更新聊天室自定义属性 在线用户人数
|
|
|
+ $easemob = new Easemoblib();
|
|
|
+ $matedata = [
|
|
|
+ 'online_user_num' => count($this->redis->hGetAll("online_".$partyid)),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($room_id,$uid,$matedata);
|
|
|
}
|
|
|
|
|
|
//出去房间
|
|
|
if($uid && $partyid && $is_chatroom && $operation == 'out' && $error_code){
|
|
|
- $roomId = $partyid;
|
|
|
+
|
|
|
$userId = $uid;
|
|
|
|
|
|
- $this->redis->HDel("online_" . $roomId, $userId);
|
|
|
- $this->redis->zRem("party_user_".$roomId,$userId); //新加的
|
|
|
+ $this->redis->HDel("online_" . $partyid, $userId);
|
|
|
+ $this->redis->zRem("party_user_".$partyid,$userId); //新加的
|
|
|
// 扣除在线用户在房间情况
|
|
|
$this->redis->hDel("livingUser",$userId);
|
|
|
|
|
|
// 更新房间在线状态
|
|
|
- $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
+ $partyInfo = $this->redis->get("party_" . $partyid);
|
|
|
if ($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo, true);
|
|
|
- $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $partyid));
|
|
|
if ($memCount <= 0) {
|
|
|
$partyInfo["is_online"] = 0;
|
|
|
- $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
+ $this->redis->set("party_" . $partyid, json_encode($partyInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $partyid]);
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
- $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
+ $liveInfo = $this->redis->get("live_" . $partyid);
|
|
|
if ($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo, true);
|
|
|
- $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $partyid));
|
|
|
if ($memCount <= 0) {
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
- \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
+ $this->redis->set("live_" . $partyid, json_encode($liveInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $partyid]);
|
|
|
$rs_user = Db::name('user')->where('id',$userId)->update(['is_live'=>0]);
|
|
|
}
|
|
|
}
|
|
@@ -290,7 +297,7 @@ class Easemob extends Api
|
|
|
//退出房间获取房间自定义属性
|
|
|
//清理这个人的麦序
|
|
|
//重置房间在线人数
|
|
|
- $this->clean_room($roomId,$uid);
|
|
|
+ $this->clean_room($partyid,$uid);
|
|
|
|
|
|
}
|
|
|
|