Jelajahi Sumber

退出房间,清空待唱歌曲

lizhen_gitee 1 tahun lalu
induk
melakukan
06b79238af
2 mengubah file dengan 33 tambahan dan 16 penghapusan
  1. 30 13
      application/api/controller/Easemob.php
  2. 3 3
      application/api/controller/Party.php

+ 30 - 13
application/api/controller/Easemob.php

@@ -277,10 +277,6 @@ class Easemob extends Api
         //获取所有麦位,假设8个
         $easemob = new Easemoblib();
         $seatlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['seat0','seat1','seat2','seat3','seat4','seat5','seat6','seat7']);
-        if(empty($seatlist)){
-            //默认为空
-            return false;
-        }
 
         $newseat = [
             'charm'    => 0,                    //红心,魅力值
@@ -300,27 +296,48 @@ class Easemob extends Api
         ];
 
         $matedata = [];
-        foreach($seatlist as $k => $seat){
-            $seat = json_decode($seat,true);
+        if(!empty($seatlist)){
+            foreach($seatlist as $k => $seat){
+                $seat = json_decode($seat,true);
 
-            //找到当前用户所在的麦位
-            if(isset($seat['rtcUid']) && !empty($seat['rtcUid']) && $seat['rtcUid'] == $uid){
-                //$newseat['seatIndex'] = substr($k,-1);
+                //找到当前用户所在的麦位
+                if(isset($seat['rtcUid']) && !empty($seat['rtcUid']) && $seat['rtcUid'] == $uid){
+                    //$newseat['seatIndex'] = substr($k,-1);
 
-                //初始化这个麦位
-                $matedata = [
-                    $k  => json_encode($newseat),
-                ];
+                    //初始化这个麦位
+                    $matedata = [
+                        $k  => json_encode($newseat),
+                    ];
 
+                }
             }
         }
 
         //重置房间在线人数
         $matedata['online_user_num'] = count($this->redis->hGetAll("online_".$party_info['id']));
+
+        //删除他点的歌曲
+        $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
+        if(isset($singlist['waitsing_list']) && !empty($singlist['waitsing_list'])){
+            $singlist = json_decode($singlist['waitsing_list'],true);
+
+            //轮询,找到,删除
+            foreach($singlist as $key => $sing){
+                if($sing['userNo'] == $uid){
+                    unset($singlist[$key]);
+                }
+            }
+            $matedata['waitsing_list'] = json_encode($singlist);
+
+        }
+
+        //修改属性
         if(!empty($matedata)){
             $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
         }
 
+
+
         return true;
     }
 

+ 3 - 3
application/api/controller/Party.php

@@ -1025,8 +1025,8 @@ class Party extends Api
             ];
             $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
 
-            //清除这个人点的歌
-            $easemob_room_id = $partyInfo['easemob_room_id'];
+            //清除这个人点的歌,前台自己处理了
+            /*$easemob_room_id = $partyInfo['easemob_room_id'];
             $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
             $singlist = json_decode($singlist['waitsing_list'],true);
 
@@ -1046,7 +1046,7 @@ class Party extends Api
                 ];
                 $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$partyInfo['user_id'],$matedata);
 
-            }
+            }*/
 
         }