WebDevSimplified / Zoom-Clone-With-WebRTC

1.52k stars 865 forks source link

No broadcasting to upcoming connections #6

Open ankitchouhan1020 opened 4 years ago

ankitchouhan1020 commented 4 years ago

Bug: Broadcasting of "user-connected" event is done only for previous nodes. If a connection is made in future, it won't have any record of previous users. So if I close one of my previous connection, the stream of that user on connections that have been made after that connection will be freeze and user needs to refresh the browser to clear it.

socket.on("user-disconnected", (userId) => {
  if (peers[userId]) {
    console.log(userId, " closed");
    peers[userId].close();
  }
});

peers[userId] will show undefined behaviour since peers don't have record of previous connections.

ankitchouhan1020 commented 4 years ago

One solution of this may be to store records on the server for all rooms and their peers. I tried but failed to do that.