吉安感知网项目-前端
张含笑
2026-01-29 9fb4de853fc8aab2000f312ba2b8907e3dc9a61d
applications/drone-command/src/views/audioCall.vue
@@ -36,7 +36,7 @@
  import { ref, computed, onBeforeUnmount } from 'vue'
  
  /** ✅ 你的 WS 地址前缀(后面拼 userId) */
  const WS_BASE = 'wss://域名/ws/chat?userId='
const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId='
  
  const uid = ref('2')
  const peerUid = ref('3')
@@ -64,11 +64,13 @@
   const s = String(seconds.value % 60).padStart(2, '0')
   return `${m}:${s}`
  })
  function startTimer() {
   stopTimer()
   seconds.value = 0
   timer = setInterval(() => seconds.value++, 1000)
  }
  function stopTimer() {
   if (timer) clearInterval(timer)
   timer = null
@@ -76,6 +78,7 @@
  
  // 心跳
  let pingTimer = null
  function startPing() {
   stopPing()
   // 每 25 秒发一次 ping(你后端有 PING/PONG)
@@ -83,6 +86,7 @@
     if (connected.value) send('ping', 'system', null)
   }, 25000)
  }
  function stopPing() {
   if (pingTimer) clearInterval(pingTimer)
   pingTimer = null
@@ -131,7 +135,8 @@
     const stream = e.streams[0]
     if (remoteAudio.value) {
      remoteAudio.value.srcObject = stream
      remoteAudio.value.play().catch(() => {})
         remoteAudio.value.play().catch(() => {
         })
     }
   }
  
@@ -406,7 +411,8 @@
  function cleanup(sendToPeer) {
   try {
     if (sendToPeer) send('hangup', peerUid.value, null)
   } catch {}
   } catch {
   }
  
   stopTimer()