Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sweng-group-15
liowebrtc
Commits
ce4a2ebe
Commit
ce4a2ebe
authored
Oct 29, 2019
by
Moritz Langenstein
Browse files
(ml5717) Backoff in room join / random peer connect if attempt already ongoing
parent
7e94603d
Changes
2
Hide whitespace changes
Inline
Side-by-side
dist/liowebrtc.js
View file @
ce4a2ebe
...
...
@@ -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
...
...
src/liowebrtc.js
View file @
ce4a2ebe
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment