fishjam-dev / react-native-membrane-webrtc

Apache License 2.0
78 stars 8 forks source link

Disconnect not firing #139

Closed Tonyhaenn closed 10 months ago

Tonyhaenn commented 12 months ago

I'm having trouble with the disconnect function. It doesn't appear to be successfully disconnecting from my membrane webrtc server.

This is my disconnect function which I attach to the provider.

  const disconnect = useCallback(async () =>{
    console.log("Attempting to disconnect")
    membraneDisconnect().then(() => {
      console.log("Disconnected")
      toggleMicrophone();
      setIsConnected(false);
    }).catch((error) => {
      console.log("Error disconnecting: " + error)
    });

  }, [])

Then I'm using useFocusEffect in my view to manage the disconnect logic (I want someone to disconnect when they leave the current screen).

  useFocusEffect(useCallback(()=>{
    //Connect with the screen is focused
    const connectParams = {
      childrenNames: params.childrenNames as string,
      talkAbout: params.talkAbout as string
    }
    connect(connectParams);
    //Disconnect on blur
    return ()=>{
      disconnect();
    }
  }, []))

In my log, I can see the "disconnected" message in react-native. But on my membrane server, I still see the log messages indicating the client is connected. The microphone isn't toggled off properly, and since I'm using a simple echo endpoint for testing right now, I still hear my voice echo'd back.

incubo4u commented 11 months ago

Thank you for reporting the bug 🦾 It has been fixed in version 7.0.1. If it reoccurs, please let us know. Your feedback is highly appreciated!