Browse Source

用户进出放进回调

lizhen_gitee 1 year ago
parent
commit
7fbeb370bd
1 changed files with 67 additions and 67 deletions
  1. 67 67
      application/api/controller/Tenim.php

+ 67 - 67
application/api/controller/Tenim.php

@@ -679,81 +679,81 @@ exit;
 
                 }
                 break;
-//            case 'Group.CallbackAfterNewMemberJoin': // 新成员入群
-//                $redis = new Redis();
-//                $redisconfig = config("redis");
-//                $redis->connect($redisconfig["host"], $redisconfig["port"]);
-                /*if ($redisconfig['redis_pwd']) {
+            case 'Group.CallbackAfterNewMemberJoin': // 新成员入群
+                $redis = new Redis();
+                $redisconfig = config("redis");
+                $redis->connect($redisconfig["host"], $redisconfig["port"]);
+                if ($redisconfig['redis_pwd']) {
                     $redis->auth($redisconfig['redis_pwd']);
                 }
                 if($redisconfig['redis_selectdb'] > 0){
                     $redis->select($redisconfig['redis_selectdb']);
-                }*/
-//                $members = $input["NewMemberList"];
-//                if($members) foreach($members as $k => $v) {
-//                    $redis->hSet("online_".$input["GroupId"],$v["Member_Account"],$v["Member_Account"]);
-//                    // 更新房间在线状态
-//                    $party_id = $input["GroupId"];
-//                    $partyInfo = $redis->get("party_".$party_id);
-//                    if($partyInfo) {
-//                        $partyInfo = json_decode($partyInfo,true);
-//                        if($partyInfo["is_online"] != 1) {
-//                            $partyInfo["is_online"] = 1;
-//                            $redis->set("party_".$party_id,json_encode($partyInfo));
-//                            \app\common\model\Party::update(["is_online"=>1],["id"=>$party_id]);
-//                        }
-//                    }
-//                }
-//                $res = [];
-//                $res["ActionStatus"] = "OK";
-//                $res["ErrorCode"] = 0;
-//                $res["ErrorInfo"] = "";
-//                echo json_encode($res);
-//                break;
-//            case 'Group.CallbackAfterMemberExit': // 成员离开
-//                $redis = new Redis();
-//                $redisconfig = config("redis");
-//                $redis->connect($redisconfig["host"], $redisconfig["port"]);
-                /*if ($redisconfig['redis_pwd']) {
+                }
+                $members = $input["NewMemberList"];
+                if($members) foreach($members as $k => $v) {
+                    $redis->hSet("online_".$input["GroupId"],$v["Member_Account"],$v["Member_Account"]);
+                    // 更新房间在线状态
+                    $party_id = $input["GroupId"];
+                    $partyInfo = $redis->get("party_".$party_id);
+                    if($partyInfo) {
+                        $partyInfo = json_decode($partyInfo,true);
+                        if($partyInfo["is_online"] != 1) {
+                            $partyInfo["is_online"] = 1;
+                            $redis->set("party_".$party_id,json_encode($partyInfo));
+                            \app\common\model\Party::update(["is_online"=>1],["id"=>$party_id]);
+                        }
+                    }
+                }
+                $res = [];
+                $res["ActionStatus"] = "OK";
+                $res["ErrorCode"] = 0;
+                $res["ErrorInfo"] = "";
+                echo json_encode($res);
+                break;
+            case 'Group.CallbackAfterMemberExit': // 成员离开
+                $redis = new Redis();
+                $redisconfig = config("redis");
+                $redis->connect($redisconfig["host"], $redisconfig["port"]);
+                if ($redisconfig['redis_pwd']) {
                     $redis->auth($redisconfig['redis_pwd']);
                 }
                 if($redisconfig['redis_selectdb'] > 0){
                     $redis->select($redisconfig['redis_selectdb']);
-                }*/
-//                $members = $input["ExitMemberList"];
-//                if($members) foreach($members as $k => $v) {
-//                    $redis->HDel("online_".$input["GroupId"],$v["Member_Account"]);
-//                }
-//                // 更新房间在线状态
-//                $party_id = $input["GroupId"];
-//                $partyInfo = $redis->get("party_".$party_id);
-//                if($partyInfo) {
-//                    $partyInfo = json_decode($partyInfo,true);
-//                    $memCount = count($redis->hGetAll("online_".$party_id));
-//                    if($memCount <= 0) {
-//                        $partyInfo["is_online"] = 0;
-//                        $redis->set("party_".$party_id,json_encode($partyInfo));
-//                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
-//                    }
-//                }
-//
-//                $liveInfo = $redis->get("live_".$party_id);
-//                if($liveInfo) {
-//                    $liveInfo = json_decode($liveInfo,true);
-//                    $memCount = count($redis->hGetAll("online_".$party_id));
-//                    if($memCount <= 0) {
-//                        $liveInfo["is_online"] = 0;
-//                        $redis->set("live_".$party_id,json_encode($liveInfo));
-//                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
-//                    }
-//                }
-//
-//                $res = [];
-//                $res["ActionStatus"] = "OK";
-//                $res["ErrorCode"] = 0;
-//                $res["ErrorInfo"] = "";
-//                echo json_encode($res);
-//                break;
+                }
+                $members = $input["ExitMemberList"];
+                if($members) foreach($members as $k => $v) {
+                    $redis->HDel("online_".$input["GroupId"],$v["Member_Account"]);
+                }
+                // 更新房间在线状态
+                $party_id = $input["GroupId"];
+                $partyInfo = $redis->get("party_".$party_id);
+                if($partyInfo) {
+                    $partyInfo = json_decode($partyInfo,true);
+                    $memCount = count($redis->hGetAll("online_".$party_id));
+                    if($memCount <= 0) {
+                        $partyInfo["is_online"] = 0;
+                        $redis->set("party_".$party_id,json_encode($partyInfo));
+                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
+                    }
+                }
+
+                $liveInfo = $redis->get("live_".$party_id);
+                if($liveInfo) {
+                    $liveInfo = json_decode($liveInfo,true);
+                    $memCount = count($redis->hGetAll("online_".$party_id));
+                    if($memCount <= 0) {
+                        $liveInfo["is_online"] = 0;
+                        $redis->set("live_".$party_id,json_encode($liveInfo));
+                        \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
+                    }
+                }
+
+                $res = [];
+                $res["ActionStatus"] = "OK";
+                $res["ErrorCode"] = 0;
+                $res["ErrorInfo"] = "";
+                echo json_encode($res);
+                break;
            /* case 'Group.CallbackBeforeSendMsg': // 群内发送消息之前
 
                 $config = config("wxMiniProgram");