lazorfuzz / liowebrtc

An event-based WebRTC library that makes it easy to embed real-time peer to peer communication into UI components.
MIT License
164 stars 10 forks source link

Peer.Nick Always Undefined #27

Open rachel-elas-ai opened 2 years ago

rachel-elas-ai commented 2 years ago

The peer.nick value always returns undefined, even though it's present in the Peer object. For instance, I pass a nickname to the Liowebrtc component as shown below:

<LioWebRTC
        options={{ debug: true,
                   dataOnly: true,
                   nick: "Pippin" }}
        onReady={join}
        onCreatedPeer={handleCreatedPeer}
        onReceivedPeerData={handlePeerData}  >

If I print the peer object to console in handleCreatedPeer, I can see peer has a nick with value "Pippin." However, trying to call peer.nick or peer["nick"] always produces undefined.

For instance,

    console.log("Peer id: ", peer.id);  // valid value
    console.log("Peer nick: ", peer.nick);  // undefined
    console.log("Peer one: ", peer.oneway);  // valid value

even though:

image

If I call `Object.keys()` on Peer, I get

image

As you can see, nick is missing, even though it's there when you log the object in its entirety.