react-native-peerjs icon indicating copy to clipboard operation
react-native-peerjs copied to clipboard

Peer js call.on('stream', ...) is undefined after calling peer.call

Open harsh317 opened this issue 3 years ago • 1 comments

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 avatar Dec 11 '21 13:12 harsh317

@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

Naveen562117 avatar Aug 22 '22 13:08 Naveen562117