Room-Code: Retry in joinFromRoomCode (10x500ms) für Offer-Race-Condition
This commit is contained in:
parent
2a86156d95
commit
1e7262ee24
1 changed files with 4 additions and 2 deletions
6
p2p.js
6
p2p.js
|
|
@ -175,11 +175,13 @@ class MeshNet {
|
||||||
this._pendingPeer = { peer, peerId: remoteId, connected: answerSent };
|
this._pendingPeer = { peer, peerId: remoteId, connected: answerSent };
|
||||||
}
|
}
|
||||||
|
|
||||||
joinFromRoomCode(code) {
|
joinFromRoomCode(code, _retries = 10) {
|
||||||
const key = `rp2p_offer_${code.toUpperCase()}`;
|
const key = `rp2p_offer_${code.toUpperCase()}`;
|
||||||
const offerStr = localStorage.getItem(key);
|
const offerStr = localStorage.getItem(key);
|
||||||
if (!offerStr) {
|
if (!offerStr) {
|
||||||
console.error('Room not found:', code);
|
if (_retries > 0) {
|
||||||
|
setTimeout(() => this.joinFromRoomCode(code, _retries - 1), 500);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const offerData = JSON.parse(offerStr);
|
const offerData = JSON.parse(offerStr);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue