I'm new in WebRTC and javascript. I want to connect with more than two people. So I need to create offer to each player. But when I'm in the promise method, I can't read value of variable.
var pc = {};
for(i=0;i<=otherplayers.length-1;i++){
pc[otherplayers[i]]= new RTCPeerConnection(servers);
pc[otherplayers[i]].createOffer()
.then(offer => pc[otherplayers[i]].setLocalDescription(offer) )
.then(() => sendMessage("offer",myid, JSON.stringify({'sdp':pc[otherplayers[i]].localDescription})) );
}
Each "otherplayers[i]"
after "then."
can't be use .
Is there anything i miss?