Bläddra i källkod

没人的麦位,seatIndex值为-1

lizhen_gitee 1 år sedan
förälder
incheckning
fdd56fe632
2 ändrade filer med 12 tillägg och 9 borttagningar
  1. 2 2
      application/api/controller/Easemob.php
  2. 10 7
      application/api/controller/Party.php

+ 2 - 2
application/api/controller/Easemob.php

@@ -332,7 +332,7 @@ class Easemob extends Api
             'userNo'         => '',               // 座位上用户no
             'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
             'name'           => '',                 // 座位上用户昵称
-            'seatIndex'      => 0,               // 座位编号
+            'seatIndex'      => -1,               // 座位编号
             'chorusSongCode' => '',             // 是否合唱
             'isAudioMuted'   => 1,            // 是否静音
             'isVideoMuted'   => 0,            // 是否开启视频
@@ -346,7 +346,7 @@ class Easemob extends Api
 
             //找到当前用户所在的麦位
             if(isset($seat['rtcUid']) && !empty($seat['rtcUid']) && $seat['rtcUid'] == $uid){
-                $newseat['seatIndex'] = substr($k,-1);
+                //$newseat['seatIndex'] = substr($k,-1);
 
                 //初始化这个麦位
                 $matedata = [

+ 10 - 7
application/api/controller/Party.php

@@ -313,7 +313,7 @@ class Party extends Api
                 'userNo'         => '',               // 座位上用户no
                 'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
                 'name'           => '',                 // 座位上用户昵称
-                'seatIndex'      => $i,               // 座位编号
+                'seatIndex'      => -1,               // 座位编号
                 'chorusSongCode' => '',             // 是否合唱
                 'isAudioMuted'   => 1,            // 是否静音
                 'isVideoMuted'   => 0,            // 是否开启视频
@@ -321,13 +321,14 @@ class Party extends Api
                 'isUsed'         => true,          // 用于送礼物选择用户
             ];
 
-            //创建完房间就进入,所以房主直接在麦位1
-            if($i == 1){
+            //创建完房间就进入,所以房主直接在麦位0
+            if($i == 0){
                 $seat['isMaster'] = true;
                 $seat['headUrl']  = localpath_to_netpath($this->auth->avatar);
                 $seat['userNo']   = $this->auth->id;
                 $seat['rtcUid']   = $this->auth->id;
                 $seat['name']     = $this->auth->nickname;
+                $seat['seatIndex'] = $i;
             }
 
             $seatdata['seat'.$i] = json_encode($seat);
@@ -440,7 +441,7 @@ class Party extends Api
                     'userNo'         => '',               // 座位上用户no
                     'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
                     'name'           => '',                 // 座位上用户昵称
-                    'seatIndex'      => $i,               // 座位编号
+                    'seatIndex'      => -1,               // 座位编号
                     'chorusSongCode' => '',             // 是否合唱
                     'isAudioMuted'   => 1,            // 是否静音
                     'isVideoMuted'   => 0,            // 是否开启视频
@@ -1464,7 +1465,7 @@ class Party extends Api
             'userNo'         => $baomai_user['user_id'],               // 座位上用户no
             'rtcUid'         => $baomai_user['user_id'],               // 座位上用户id,与rtc的userId一致
             'name'           => $baomai_user['nickname'],                 // 座位上用户昵称
-            'seatIndex'      => 0,               // 座位编号
+            'seatIndex'      => -1,               // 座位编号
             'chorusSongCode' => '',             // 是否合唱
             'isAudioMuted'   => 1,            // 是否静音
             'isVideoMuted'   => 0,            // 是否开启视频
@@ -1473,6 +1474,7 @@ class Party extends Api
         ];
 
         if(empty($seatlist)){
+            $newseat['seatIndex'] = 0;
             $matedata['seat0'] = $newseat;
         }else{
             //第一遍轮询麦位,尝试找到这个人,如果找到在任何一个麦位,立刻return
@@ -2566,7 +2568,7 @@ class Party extends Api
     //轮询所有房间,挨个初始化自定义属性
     public function room_task(){
 
-        $ids = Db::name('party')->where('id',1)->select();
+        $ids = Db::name('party')->select();
 
         $easemob = new Easemob();
         foreach($ids as $key => $party){
@@ -2596,7 +2598,7 @@ class Party extends Api
                     'userNo'         => '',               // 座位上用户no
                     'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
                     'name'           => '',                 // 座位上用户昵称
-                    'seatIndex'      => $i,               // 座位编号
+                    'seatIndex'      => -1,               // 座位编号
                     'chorusSongCode' => '',             // 是否合唱
                     'isAudioMuted'   => 1,            // 是否静音
                     'isVideoMuted'   => 0,            // 是否开启视频
@@ -2612,6 +2614,7 @@ class Party extends Api
                     $seat['userNo']   = $owner['id'];
                     $seat['rtcUid']   = $owner['id'];
                     $seat['name']     = $owner['nickname'];
+                    $seat['seatIndex']= $i;
                 }
 
                 $seatdata['seat'.$i] = json_encode($seat);