some-pilot-52613
08/21/2025, 7:35 PMtall-airline-16756
08/21/2025, 7:35 PMtall-airline-16756
08/21/2025, 7:37 PMroom.disconnect() to leave the room.
2. Then, stop the audio session by calling AudioSession.stopAudioSession() right after disconnecting.
3. Also, it’s super helpful to add cleanup logic inside your React component’s useEffect return function. Here’s a quick example:
useEffect(() => {
const connect = async () => {
await AudioSession.startAudioSession();
await room.connect(url, token, {});
};
connect();
return () => {
room.disconnect();
AudioSession.stopAudioSession();
};
}, [url, token, room]);
One more thing—if you have any local audio tracks that you’re done with, make sure to stop those too. The SDK does a great job handling this automatically when stopOnMute is enabled.
If you run into any issues or want to chat more about this, just let me know—I’m here to help!
Sources: src/index.tsx | src/room/track/LocalAudioTrack.ts | app/assistant/index.tsxsome-pilot-52613
08/21/2025, 7:40 PM