I have implemented WebRTC based video calling using react-native-webrtc. Its a one to one calling and works fine, but when I disconnect the call and try to reconnect again then the reconnection takes a lot of time and sometimes hangs the application. Below is the code for disconnecting:
function stopLocalStream() {
if (friends != null) {
friends.forEach(friend => {
leave(friend.socketId)
})
}
if (localStream != null) {
localStream.getTracks().forEach(t => t.stop())
localStream.release()
localStream = null
}
}
function leave(socketId) {
console.log('leave', socketId)
var pc = peerConnections[socketId]
if (pc) {
pc.close()
}
delete peerConnections[socketId]
if (onFriendLeftCallback != null) {
onFriendLeftCallback(socketId)
}
}
I think that i am not disconnecting the video call correctly. Any Help would be much appreciated thanks.
from Disconnecting from a video call using react-native-webrtc
No comments:
Post a Comment