Я реализую функцию, позволяющую пользователям присоединяться к живому классу в приложении 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
100 мс ON_TRACK_UPDATE и ON_PEER_UPDATE не запускаются в React Native ⇐ Javascript
Форум по Javascript
1763892835
Anonymous
Я реализую функцию, позволяющую пользователям присоединяться к живому классу в приложении 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-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]);
Подробнее здесь: [url]https://stackoverflow.com/questions/79827740/100ms-on-track-update-and-on-peer-update-is-not-firing-in-react-native[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия