I'm implementing a feature that users can join a live class in a React Native app. For that, I need to listen to the events like new peer joined, video turned on/off...
based on 100ms docs, the below code should work; why are onTrackListener and onPeerListener not being called?
useEffect(() => { if(!roomCode || !userName){ return; } const joinRoom = async () => { // Prevent multiple join attempts try { setIsJoining(true); setLoading(true); /** * creating {@link HMSSDK} instance to join room * For more info, Check out {@link https://www.100ms.live/docs/react-native/v2/features/join#join-a-room | Join a Room} */ const hmsInstance = await HMSSDK.build(); // Saving `hmsInstance` in ref hmsInstanceRef.current = hmsInstance; const token = await hmsInstance.getAuthTokenByRoomCode(roomCode); /** * Adding HMSSDK Event Listeners before calling Join method on HMSSDK instance */ hmsInstance.addEventListener(HMSUpdateListenerActions.ON_JOIN, onJoinSuccess); hmsInstance.addEventListener(HMSUpdateListenerActions.ON_PEER_UPDATE, onPeerListener); hmsInstance.addEventListener(HMSUpdateListenerActions.ON_TRACK_UPDATE, onTrackListener); hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onErrorListener); hmsInstance.addEventListener(HMSUpdateListenerActions.ON_MESSAGE, onMessageListener); /** * Joining Room */ console.log("Attempting to join room with user:", userName); hmsInstance.join(new HMSConfig({ authToken: token, username: userName })); } catch (error) { console.error("Join room error:", error); setIsJoining(false); Alert.alert('Error', 'Failed to join room. Please try again.'); } finally{ setLoading(false); } }; joinRoom(); // Cleanup function return () => { handleRoomLeave(); }; }, [roomCode, userName]);