dusenyao 3 年之前
父節點
當前提交
6efbf09063

+ 15 - 0
src/api/live.js

@@ -284,3 +284,18 @@ export function GetMyGroupInfo_Teacher(data) {
     data
   });
 }
+
+/**
+ * 学员连线处理
+ * @param {Object} data
+ */
+export function DealStudentConnection(data) {
+  let params = getRequestParams('live_room-live_room_dispatch-DealStudentConnection');
+
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params,
+    data
+  });
+}

+ 15 - 1
src/views/live/student/index.vue

@@ -144,7 +144,8 @@ import {
   GetCurMaterialSent,
   GetLiveRoomInfo,
   GetGroupStatus,
-  CreateEnterLiveRoomSession
+  CreateEnterLiveRoomSession,
+  DealStudentConnection
 } from '@/api/live';
 import { app } from '@/store/mutation-types';
 import SelectDevice from '../SelectDevice.vue';
@@ -346,6 +347,7 @@ export default {
         uid: this.room_user_id,
         success: str => {
           this.callLoading = false;
+          this.dealStudentConnection(this.room_user_id, 0, this.roomInfo.video_mode);
           console.log('下麦成功', str);
           common.updateMcResult('', 0);
           this.$message.success('下麦成功');
@@ -358,6 +360,17 @@ export default {
       });
     },
 
+    dealStudentConnection(room_user_id, deal_mode, connection_mode) {
+      DealStudentConnection({
+        task_id: this.task_id,
+        room_user_id,
+        deal_mode,
+        connection_mode
+      }).then(() => {
+        this.getLiveRoomStudentList();
+      });
+    },
+
     // 发消息
     sendMsg() {
       common.sendMsg(this.msg);
@@ -377,6 +390,7 @@ export default {
     inviteAccept() {
       common.inviteAccept({
         success: str => {
+          this.dealStudentConnection(this.room_user_id, 2, this.roomInfo.video_mode);
           console.log('接受邀请成功', str);
         },
         fail: data => {

+ 1 - 1
src/views/live/student/live.js

@@ -207,7 +207,6 @@ export function initListener(vue) {
 
   // 网络整体状态事件
   rtc.on('netStatus', data => {
-    console.log(data.netStatus);
     vue.netStatus = data.netStatus;
   });
 
@@ -246,6 +245,7 @@ export function initListener(vue) {
   // 监听自己被邀请事件
   rtc.on('inviteUp', uid => {
     console.log('监听自己被邀请事件', uid);
+    vue.dealStudentConnection(uid, 1, vue.roomInfo.video_mode);
     vue.callLoading = true;
     vue.invite = true;
   });

+ 1 - 8
src/views/live/teacher/group.js

@@ -1,14 +1,7 @@
 import store from '@/store';
 import { Message } from 'element-ui';
 import { rtc, updateMcResult, createScript } from '@/views/live/common';
-export {
-  initSDK,
-  sendMsg,
-  sendPublishMessage,
-  closeVideo,
-  roomUpdate,
-  chatRoll
-} from '@/views/live/common';
+export { initSDK, sendMsg, closeVideo, roomUpdate, chatRoll } from '@/views/live/common';
 
 /**
  * 推送本地流

+ 39 - 9
src/views/live/teacher/index.vue

@@ -32,7 +32,7 @@
               正在呼叫【{{ connectStudent.student_name }}】,等待对方接通...
             </p>
             <div>
-              <el-button type="danger" circle @click="handsDown('loading')">
+              <el-button type="danger" circle @click="handsDown">
                 <svg-icon icon-class="hang-up" />
               </el-button>
             </div>
@@ -149,8 +149,18 @@
                 <span class="name">{{ item.student_name }}</span>
               </div>
               <div class="student-list-right">
-                <svg-icon icon-class="video" @click="invite(item, 1)" />
-                <svg-icon icon-class="voice" @click="invite(item, 2)" />
+                <svg-icon
+                  v-if="item.connection_mode === 1 && item.connection_status !== 0"
+                  icon-class="hang-up"
+                  @click="handsDown"
+                />
+                <svg-icon v-else icon-class="video" @click="invite(item, 1)" />
+                <svg-icon
+                  v-if="item.connection_mode === 2 && item.connection_status !== 0"
+                  icon-class="hang-up"
+                  @click="handsDown"
+                />
+                <svg-icon v-else icon-class="voice" @click="invite(item, 2)" />
               </div>
             </li>
           </ul>
@@ -206,7 +216,8 @@ import {
   GetLiveRoomInfo,
   StudentExitLiveRoom,
   StartGroup,
-  GetGroupStatus
+  GetGroupStatus,
+  DealStudentConnection
 } from '@/api/live';
 import { app } from '@/store/mutation-types';
 import SelectMaterial from '@/components/live/SelectMaterial.vue';
@@ -452,14 +463,14 @@ export default {
         .then(({ video_mode }) => {
           let uid = student.room_user_id;
           if (video_mode === mode) {
-            this.inviteStudent(uid, student);
+            this.inviteStudent(uid, student, mode);
           } else {
             common.roomUpdate({
               video_mode: mode,
               roomUpdateSuccess: data => {
                 console.log(data, '连麦音视频模式更新请求成功!');
                 this.roomInfo.video_mode = mode;
-                this.inviteStudent(uid, student);
+                this.inviteStudent(uid, student, mode);
               },
               roomUpdateFailed: data => {
                 this.callLoading = false;
@@ -475,11 +486,12 @@ export default {
         });
     },
 
-    inviteStudent(uid, connectStudent) {
+    inviteStudent(uid, connectStudent, mode) {
       common.invite({
         uid,
         success: str => {
           console.log('邀请上麦成功', str);
+          this.dealStudentConnection(uid, 1, mode);
           common.sendPublishMessage({
             type: 'inviteImage',
             connectStudent
@@ -493,17 +505,29 @@ export default {
       });
     },
 
+    dealStudentConnection(room_user_id, deal_mode, connection_mode) {
+      DealStudentConnection({
+        task_id: this.task_id,
+        room_user_id,
+        deal_mode,
+        connection_mode
+      }).then(() => {
+        this.getLiveRoomStudentList();
+      });
+    },
+
     // 下麦
-    handsDown(type) {
+    handsDown() {
       common.handsDown({
         uid: this.connectStudent.room_user_id,
         success: str => {
-          if (type === 'loading') {
+          if (this.callLoading) {
             common.sendPublishMessage({
               type: 'handsDown-load',
               uid: this.connectStudent.room_user_id
             });
           }
+          this.dealStudentConnection(this.connectStudent.room_user_id, 0, this.roomInfo.video_mode);
 
           this.callLoading = false;
           this.connectStudent = '';
@@ -937,6 +961,7 @@ $live-bc: #3d3938;
     }
 
     &-right {
+      height: 794px;
       padding: 8px;
       background-color: #2c2c2c;
       border-end-end-radius: 8px;
@@ -988,6 +1013,11 @@ $live-bc: #3d3938;
           margin-bottom: 16px;
         }
 
+        ul {
+          height: calc(100% - 18px);
+          overflow: auto;
+        }
+
         li {
           display: flex;
           margin-bottom: 16px;

+ 18 - 13
src/views/live/teacher/live.js

@@ -159,14 +159,14 @@ export function initListener(vue) {
   });
 
   // 新增订阅流事件
-  rtc.on('allow_sub', function (stream) {
-    if (stream.isMixed()) {
+  rtc.on('allow_sub', tryStream => {
+    if (tryStream.isMixed()) {
       console.log('是混合流,不订阅');
     } else {
       // 订阅远程流
       rtc.trySubscribeStream({
-        tryStream: stream,
-        success: function (stream) {
+        tryStream,
+        success(stream) {
           // 订阅流成功
           let streamType = stream.streamType();
           vue.remoteStreamType = streamType;
@@ -177,8 +177,11 @@ export function initListener(vue) {
             vue.connect = true;
             vue.callLoading = false;
           }
+          if (streamType === 10) {
+            vue.dealStudentConnection(vue.connectStudent.room_user_id, 2, vue.roomInfo.video_mode);
+          }
         },
-        fail: function (err) {
+        fail(err) {
           console.log('订阅流失败', err);
         }
       });
@@ -237,7 +240,6 @@ export function initListener(vue) {
 
   // 网络整体状态事件
   rtc.on('netStatus', data => {
-    console.log(data.netStatus);
     vue.netStatus = data.netStatus;
   });
 
@@ -259,22 +261,25 @@ export function initListener(vue) {
   });
 
   // 监听通知移除流事件
-  rtc.on('stream_removed', function (stream) {
-    console.log('监听通知移除流事件');
+  rtc.on('stream_removed', stream => {
+    console.log('监听通知移除流事件', stream);
     vue.connect = false;
     vue.remoteStreamType = -1;
+    if (typeof vue.connectStudent === 'object' && stream.streamType() === 10) {
+      vue.handsDown();
+    }
   });
 
   // 停止订阅流
-  rtc.on('unSub', function (stream) {
-    console.log('停止订阅流', stream);
+  rtc.on('unSub', unSubStream => {
+    console.log('停止订阅流', unSubStream);
     rtc.unSubscribeStream({
-      unSubStream: stream,
-      success: function (stream) {
+      unSubStream,
+      success(stream) {
         console.log('取消订阅流成功', stream.id());
       },
 
-      fail: function (str) {
+      fail(str) {
         console.log(str);
       }
     });