Commit ce4a2ebe authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) Backoff in room join / random peer connect if attempt already ongoing

parent 7e94603d
......@@ -520,10 +520,21 @@ var LioWebRTC = function (_WildEmitter) {
console.log('Received peer info about', id, 'on room join');
var peerCount = _this5.webrtc.getPeers().length;
var peers = self.webrtc.getPeers(id, type);
var backoff = false;
peers.forEach(function (p) {
console.log('Peer with same ID in state', p.pc.pc.iceConnectionState, 'found');
if (p.pc.pc.iceConnectionState == 'new' || p.pc.pc.iceConnectionState == 'checking') {
backoff = true;
return;
}
p.end(false);
peerCount--;
});
if (backoff) {
return {
v: void 0
};
}
if (_this5.config.dataOnly && _this5.config.constraints.maxPeers > 0 && (peerCount >= _this5.config.constraints.minPeers || peerCount >= _this5.config.constraints.maxPeers)) {
return {
v: void 0
......@@ -634,13 +645,24 @@ var LioWebRTC = function (_WildEmitter) {
for (type in client) {
if (type !== 'turnservers' && client[type]) {
var _ret2 = function () {
console.log('Connecting to random peer', peerId);
console.log('Connecting to peer', peerId);
var peerCount = _this7.webrtc.getPeers().length;
var peers = _this7.webrtc.getPeers(peerId, type);
var backoff = false;
peers.forEach(function (p) {
console.log('Peer with same ID in state', p.pc.pc.iceConnectionState, 'found');
if (p.pc.pc.iceConnectionState == 'new' || p.pc.pc.iceConnectionState == 'checking') {
backoff = true;
return;
}
p.end(false);
peerCount--;
});
if (backoff) {
return {
v: void 0
};
}
if (_this7.config.constraints.maxPeers > 0 && peerCount >= _this7.config.constraints.maxPeers) {
return {
v: void 0
......
......@@ -424,10 +424,19 @@ class LioWebRTC extends WildEmitter {
console.log('Received peer info about', id, 'on room join')
let peerCount = this.webrtc.getPeers().length;
const peers = self.webrtc.getPeers(id, type);
let backoff = false
peers.forEach((p) => {
console.log('Peer with same ID in state', p.pc.pc.iceConnectionState, 'found')
if (p.pc.pc.iceConnectionState == 'new' || p.pc.pc.iceConnectionState == 'checking') {
backoff = true;
return;
}
p.end(false);
peerCount--;
});
if (backoff) {
return;
}
if (this.config.dataOnly && this.config.constraints.maxPeers > 0 && (peerCount >= this.config.constraints.minPeers || peerCount >= this.config.constraints.maxPeers)) {
return;
}
......@@ -506,13 +515,22 @@ class LioWebRTC extends WildEmitter {
let peer;
for (type in client) {
if (type !== 'turnservers' && client[type]) {
console.log('Connecting to random peer', peerId)
console.log('Connecting to peer', peerId)
let peerCount = this.webrtc.getPeers().length;
const peers = this.webrtc.getPeers(peerId, type);
let backoff = false
peers.forEach((p) => {
console.log('Peer with same ID in state', p.pc.pc.iceConnectionState, 'found')
if (p.pc.pc.iceConnectionState == 'new' || p.pc.pc.iceConnectionState == 'checking') {
backoff = true;
return;
}
p.end(false);
peerCount--;
});
if (backoff) {
return;
}
if (this.config.constraints.maxPeers > 0 && peerCount >= this.config.constraints.maxPeers) {
return;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment