caner 1 year ago
parent
commit
789866d09f
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/pages/room/index.vue

+ 3 - 2
src/pages/room/index.vue

@@ -47,6 +47,7 @@ onMounted(() => RTC.initRTC(remoteVideo.value, (event) => {
     console.log('可以发送控制数据')
   }
   if (type === 'answer') {
+    console.log('answer', data)
     mqtt.send(JSON.stringify(data))
   }
   if (type === 'disconnected') {
@@ -55,11 +56,11 @@ onMounted(() => RTC.initRTC(remoteVideo.value, (event) => {
   }
 }))
 
-watch(() => store.mqtt_message, async (val) => {
+watch(() => store.mqtt_message, async (val: { type: string, data?: RTCSessionDescriptionInit }) => {
   // 接收offer
   if (val.type === 'offer') {
     console.log('offer', val)
-    await RTC.Peer?.setRemoteDescription(val.data)
+    await RTC.Peer?.setRemoteDescription(val.data!)
     const answerd = await RTC.Peer?.createAnswer()
     await RTC.Peer?.setLocalDescription(answerd)
   }