Я реализую функцию, позволяющую пользователям присоединяться к живому классу в приложении React Native. Для этого мне нужно прослушивать такие события, как присоединение нового узла, включение/выключение видео...
на основании документов за 100 мс, приведенный ниже код должен работать; почему onTrackListener и onPeerListener не вызываются?
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-nativ ... oin-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]);
Подробнее здесь: https://stackoverflow.com/questions/798 ... act-native