Skip to content

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

@harsh317

Description

@harsh317

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions