googlecodelabs / webrtc-web

Realtime communication with WebRTC
https://codelabs.developers.google.com/codelabs/webrtc-web/
Apache License 2.0
755 stars 351 forks source link

Can't re-enter same room unless both peers leave #108

Closed scoolualek closed 5 years ago

scoolualek commented 5 years ago

If I have a video call going, and one person leaves and then tries to come back, he won't be able to enter the same room the other person leaves as well, and then they both re-enter. This is also a problem because if you lose your connection or refresh, you won't be able to re-enter the room.

I'm very confused. It doesn't say the room is full when I try to re-enter so it does recognize that someone disconnected. Any ideas?

scoolualek commented 5 years ago

Seems to be working now, I changed two things if anyone has a similar issue.

First, in the maybeStart function, I took out the need for isInitiator to be true to be able to call doCall(). I'm still very new to webRTC and I'm not even sure what purpose isInitiator serves, but my application seems to be working fine without using it in this function. If there is a problem with doing things this way please let me know.

After I did this, I noticed I could refresh on chrome and get back into my call, but if I did it on my iPhone, I had the same issue as before. I fixed this by changing window.onbeforeunload = function() { sendMessage('bye'); }; to

var isOnIOS = navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPhone/i); var eventName = isOnIOS ? "pagehide" : "beforeunload"; window.addEventListener(eventName, function (event) { sendMessage('bye'); } );

Apparently the before unload event is called pagehide now in iOS safari.