react-native-peerjs
react-native-peerjs copied to clipboard
Peer js call.on('stream', ...) is undefined after calling peer.call
I am making a group video call app and I have been stuck here for a long time.
See like I have this small function:
const connectToNewUser = (id, stream) => {
const call = peerServer.call(id, stream);
call.on("stream", (userVideoStream) => {
if (userVideoStream) {
setremoteStream(...remoteStream, userVideoStream);
}
});
};
And It is simply being called here:
socket.on("user-connected", (id) => {
connectToNewUser(id, MyStream);
});
And listening for the event as follows:
peerServer.on("call", (call) => {
call.answer(MyStream);
call.on("stream", (remoteUserStream) => {
setstreams(...streams, remoteUserStream);
});
});
But I am getting this error:
ERROR [TypeError: undefined is not an object (evaluating 'call.on')]
What Should I do? I have made a same app in web with the code exactly the same as this but then y I am getting this error?
@harsh317 did you happen to find any solution for this issue , I am having same issue please let me know if you know something useful to resolve this issue