streaming working slick and clean
This commit is contained in:
@@ -270,7 +270,7 @@ function StreamRoom({
|
|||||||
var peerForMeAndNewbie = new Peer({
|
var peerForMeAndNewbie = new Peer({
|
||||||
initiator: false,
|
initiator: false,
|
||||||
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times
|
trickle: false, // prevents the multiple tries on different ice servers and signal from getting called a bunch of times
|
||||||
stream: localStream, // add in my own stream that I got before
|
stream: userStream, // add in my own stream that I got before
|
||||||
});
|
});
|
||||||
|
|
||||||
peerForMeAndNewbie.on("signal", (signal) => {
|
peerForMeAndNewbie.on("signal", (signal) => {
|
||||||
@@ -309,13 +309,14 @@ function StreamRoom({
|
|||||||
// find the peer we created earlier for this master
|
// find the peer we created earlier for this master
|
||||||
// ?is this okay? using the setter to get the current state?
|
// ?is this okay? using the setter to get the current state?
|
||||||
setUserPeers((previousUserPeersMap) => {
|
setUserPeers((previousUserPeersMap) => {
|
||||||
|
const newUserPeerMap = { ...previousUserPeersMap };
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
"here is the current peers map",
|
"here is the current peers map",
|
||||||
previousUserPeersMap
|
previousUserPeersMap
|
||||||
);
|
);
|
||||||
|
|
||||||
const peerForAnswerer =
|
const peerForAnswerer = newUserPeerMap[res.answererUserId];
|
||||||
previousUserPeersMap[res.answererUserId];
|
|
||||||
|
|
||||||
if (peerForAnswerer) {
|
if (peerForAnswerer) {
|
||||||
peerForAnswerer.signal(res.simplePeerSignal);
|
peerForAnswerer.signal(res.simplePeerSignal);
|
||||||
@@ -325,7 +326,8 @@ function StreamRoom({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return previousUserPeersMap;
|
// note needed to change state so that the peer object that gets iterated in dom isn't the old referenced one/we trigger refresh for the child component
|
||||||
|
return newUserPeerMap;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user