Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
liowebrtc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
liowebrtc
Commits
3e4caec1
Commit
3e4caec1
authored
6 years ago
by
lazorfuzz
Browse files
Options
Downloads
Patches
Plain Diff
Fix repeated connection attempts on unresponsive peers
parent
2a7981df
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/liowebrtc.js
+15
-13
15 additions, 13 deletions
src/liowebrtc.js
with
15 additions
and
13 deletions
src/liowebrtc.js
+
15
−
13
View file @
3e4caec1
...
...
@@ -4,7 +4,7 @@ import mockconsole from 'mockconsole';
import
WebRTC
from
'
./webrtc
'
;
import
webrtcSupport
from
'
./webrtcsupport
'
;
import
SocketIoConnection
from
'
./socketioconnection
'
;
import
{
Graph
,
addNode
,
addConnection
,
getConnectedPeers
}
from
'
./PeerOptimizer
'
;
import
{
Graph
,
addNode
,
addConnection
,
getConnectedPeers
,
getDroppablePeers
}
from
'
./PeerOptimizer
'
;
import
{
inheritedMethods
,
defaultConfig
,
defaultChannel
}
from
'
./constants
'
;
class
LioWebRTC
extends
WildEmitter
{
...
...
@@ -82,7 +82,7 @@ class LioWebRTC extends WildEmitter {
sharemyscreen
:
message
.
roomType
===
'
screen
'
&&
!
message
.
broadcaster
,
broadcaster
:
message
.
roomType
===
'
screen
'
&&
!
message
.
broadcaster
?
self
.
connection
.
getSessionid
()
:
null
,
});
this
.
sendPing
(
peer
,
true
);
this
.
sendPing
(
peer
,
peer
.
id
,
true
);
}
else
{
return
;
}
...
...
@@ -250,7 +250,8 @@ class LioWebRTC extends WildEmitter {
peer
.
sendDirectly
(
'
_pong
'
,
[
now
,
now
-
start
],
channel
);
}
sendPing
(
peer
,
firstPing
=
false
,
channel
=
defaultChannel
)
{
sendPing
(
peer
,
peerId
,
firstPing
=
false
,
channel
=
defaultChannel
)
{
console
.
log
(
'
SENDING PING
'
,
peer
);
const
self
=
this
;
if
(
firstPing
)
peer
.
start
();
setTimeout
(()
=>
{
...
...
@@ -259,13 +260,13 @@ class LioWebRTC extends WildEmitter {
if
(
firstPing
)
this
.
emit
(
'
createdPeer
'
,
peer
);
}
else
{
// The channel is closed, remove the peer
console
.
log
(
'
removing peer, ping failed
'
);
if
(
peer
.
id
)
self
.
unconnectivePeers
[
peer
.
i
d
]
=
true
;
console
.
log
(
'
removing peer, ping failed
'
,
peerId
);
self
.
unconnectivePeers
[
peer
I
d
]
=
true
;
peer
.
end
();
this
.
getClients
((
err
,
clients
)
=>
{
console
.
log
(
'
CLIENT RESULTS
'
,
clients
);
const
ids
=
Object
.
keys
(
clients
).
filter
((
c
)
=>
{
if
(
!
self
.
unconnectivePeers
[
c
]
===
true
||
c
===
this
.
id
)
{
if
(
self
.
unconnectivePeers
[
c
]
===
true
||
c
===
this
.
id
)
{
return
false
;
}
return
true
;
...
...
@@ -381,10 +382,10 @@ class LioWebRTC extends WildEmitter {
let
peer
;
this
.
roomCount
=
Object
.
keys
(
roomDescription
.
clients
).
length
;
console
.
log
(
roomDescription
.
clients
);
console
.
log
(
roomDescription
);
this
.
id
=
roomDescription
.
you
;
this
.
unconnectivePeers
[
this
.
id
]
=
true
;
for
(
id
of
Object
.
keys
(
roomDescription
.
clients
).
reverse
())
{
for
(
id
of
Object
.
keys
(
roomDescription
.
clients
).
reverse
()
.
filter
(
item
=>
item
!==
this
.
id
)
)
{
client
=
roomDescription
.
clients
[
id
];
for
(
type
in
client
)
{
if
(
client
[
type
])
{
...
...
@@ -401,7 +402,7 @@ class LioWebRTC extends WildEmitter {
offerToReceiveVideo
:
!
this
.
config
.
dataOnly
&&
self
.
config
.
receiveMedia
.
offerToReceiveVideo
?
1
:
0
,
},
});
this
.
sendPing
(
peer
,
true
);
this
.
sendPing
(
peer
,
peer
.
id
,
true
);
}
}
}
...
...
@@ -459,17 +460,17 @@ class LioWebRTC extends WildEmitter {
}
connectToPeer
(
peerId
,
client
)
{
let
id
;
console
.
log
(
'
CONNECTING TO
'
,
peerId
)
;
let
type
;
let
peer
;
for
(
type
in
client
)
{
if
(
client
[
type
])
{
const
peerCount
=
this
.
webrtc
.
getPeers
().
length
;
if
(
this
.
config
.
network
.
maxPeers
>
0
&&
(
peerCount
>=
this
.
config
.
network
.
minPeers
||
peerCount
>=
this
.
config
.
network
.
maxPeers
)
)
{
if
(
this
.
config
.
network
.
maxPeers
>
0
&&
peerCount
>=
this
.
config
.
network
.
maxPeers
)
{
break
;
}
peer
=
this
.
webrtc
.
createPeer
({
i
d
,
peerI
d
,
type
,
enableDataChannels
:
this
.
config
.
enableDataChannels
&&
type
!==
'
screen
'
,
receiveMedia
:
{
...
...
@@ -477,7 +478,8 @@ class LioWebRTC extends WildEmitter {
offerToReceiveVideo
:
!
this
.
config
.
dataOnly
&&
this
.
config
.
receiveMedia
.
offerToReceiveVideo
?
1
:
0
,
},
});
this
.
sendPing
(
peer
,
true
);
console
.
log
(
'
ABOUT TO SEND PING
'
,
peer
);
this
.
sendPing
(
peer
,
peerId
,
true
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment