function stopSession()

in challenge4/frontend/components/voice-mode.tsx [94:111]


  function stopSession() {
    if (dataChannel) {
      dataChannel.close()
    }
    if (peerConnection.current) {
      peerConnection.current.close()
    }

    setIsSessionStarted(false)
    setIsSessionActive(false)
    setDataChannel(null)
    peerConnection.current = null
    if (audioStream) {
      audioStream.getTracks().forEach(track => track.stop())
    }
    setAudioStream(null)
    audioTransceiver.current = null
  }