Selaa lähdekoodia

下线清理麦位

lizhen_gitee 1 vuosi sitten
vanhempi
commit
85c87537c8
1 muutettua tiedostoa jossa 51 lisäystä ja 0 poistoa
  1. 51 0
      application/api/controller/Easemob.php

+ 51 - 0
application/api/controller/Easemob.php

@@ -6,6 +6,8 @@ use app\common\controller\Api;
 use Redis;
 use think\Db;
 
+use app\common\library\Easemob as Easemoblib;
+
 /**
  * 环信接口
  */
@@ -164,6 +166,7 @@ class Easemob extends Api
 
 
         //群组和聊天室操作:
+        //muc:presence 有新成员加入了聊天室
         //muc:kick 踢出聊天室
         //muc:absence 有成员离开了聊天室
         //muc:leave 成员主动退出聊天室
@@ -278,6 +281,8 @@ class Easemob extends Api
 
                 //退出房间获取房间自定义属性
                 //清理这个人的麦序
+                $this->clean_seat($roomId,$uid);
+
             }
 
         }
@@ -285,6 +290,52 @@ class Easemob extends Api
 
     }
 
+    //待唱,增加
+    public function clean_seat($easemob_room_id,$uid){
+
+        $party_info = Db::name('party')->where('easemob_room_id',$easemob_room_id)->find();
+        if(empty($party_info)){
+            return false;
+        }
+
+        //获取所有麦位,假设8个
+        $easemob = new Easemoblib();
+        $seatlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['seat1','seat2','seat3','seat4','seat5','seat6','seat7','seat8']);
+        if(empty($seatlist)){
+            //默认为空
+            return false;
+        }
+
+        $newseat = [
+            'charm'    => 0,                    //红心,魅力值
+
+            'isMaster'       => false,            // 是否是房主
+            'headUrl'        => '',              // 头像
+            'userNo'         => '',               // 座位上用户no
+            'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
+            'name'           => '',                 // 座位上用户昵称
+            'seatIndex'      => 0,               // 座位编号
+            'chorusSongCode' => '',             // 是否合唱
+            'isAudioMuted'   => 1,            // 是否静音
+            'isVideoMuted'   => 0,            // 是否开启视频
+        ];
+
+        foreach($seatlist as $k => $seat){
+            $seat = json_decode($seat,true);
+            if(isset($seat['rtcUid']) && !empty($seat['rtcUid']) && $seat['rtcUid'] == $uid){
+                $newseat['seatIndex'] = $seat['seatIndex'];
+
+                //重新设置
+                $matedata = [
+                    $k  => json_encode($newseat),
+                ];
+                $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
+            }
+        }
+
+        return true;
+    }
+
     /**
      * 获取用户所加入的聊天室
      */