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
7e94603d
Commit
7e94603d
authored
Oct 29, 2019
by
Moritz Langenstein
Browse files
(ml5717) Temporary peer getStats() fix
parent
30b37f67
Changes
4
Show whitespace changes
Inline
Side-by-side
dist/liowebrtc.js
View file @
7e94603d
...
...
@@ -356,6 +356,8 @@ var LioWebRTC = function (_WildEmitter) {
value
:
function
connectToRandomPeer
()
{
var
_this2
=
this
;
if
(
!
this
.
connection
)
return
;
this
.
getClients
(
function
(
err
,
clients
)
{
var
ids
=
Object
.
keys
(
clients
).
filter
(
function
(
c
)
{
return
!
(
_this2
.
unconnectivePeers
[
c
]
===
true
||
c
===
_this2
.
id
||
(
0
,
_PeerOptimizer
.
isNeighbor
)(
_this2
.
id
,
c
));
...
...
@@ -419,6 +421,8 @@ var LioWebRTC = function (_WildEmitter) {
},
{
key
:
'
disconnect
'
,
value
:
function
disconnect
()
{
if
(
!
this
.
connection
)
return
;
this
.
connection
.
disconnect
();
delete
this
.
connection
;
}
...
...
@@ -632,7 +636,7 @@ var LioWebRTC = function (_WildEmitter) {
var
_ret2
=
function
()
{
console
.
log
(
'
Connecting to random peer
'
,
peerId
);
var
peerCount
=
_this7
.
webrtc
.
getPeers
().
length
;
var
peers
=
self
.
webrtc
.
getPeers
(
peerId
,
type
);
var
peers
=
_this7
.
webrtc
.
getPeers
(
peerId
,
type
);
peers
.
forEach
(
function
(
p
)
{
p
.
end
(
false
);
peerCount
--
;
...
...
@@ -650,7 +654,7 @@ var LioWebRTC = function (_WildEmitter) {
offerToReceiveAudio
:
type
!==
'
screen
'
&&
!
_this7
.
config
.
dataOnly
&&
_this7
.
config
.
receiveMedia
.
offerToReceiveAudio
?
1
:
0
,
offerToReceiveVideo
:
!
_this7
.
config
.
dataOnly
&&
_this7
.
config
.
receiveMedia
.
offerToReceiveVideo
?
1
:
0
},
iceServers
:
self
.
webrtc
.
config
.
peerConnectionConfig
.
iceServers
.
concat
(
client
.
turnservers
)
iceServers
:
_this7
.
webrtc
.
config
.
peerConnectionConfig
.
iceServers
.
concat
(
client
.
turnservers
)
});
if
(
_this7
.
config
.
dataOnly
&&
_this7
.
config
.
constraints
.
maxPeers
>
0
)
{
_this7
.
sendPing
(
peer
,
peerId
,
true
);
...
...
dist/peer.js
View file @
7e94603d
...
...
@@ -296,11 +296,11 @@ var Peer = function (_WildEmitter) {
var
emitRemoval
=
arguments
.
length
>
0
&&
arguments
[
0
]
!==
undefined
?
arguments
[
0
]
:
true
;
if
(
this
.
closed
)
return
;
this
.
pc
.
close
();
this
.
handleStreamRemoved
(
emitRemoval
);
if
(
emitRemoval
)
{
this
.
parent
.
emit
(
'
removedPeer
'
,
this
);
}
this
.
pc
.
close
();
this
.
handleStreamRemoved
(
emitRemoval
);
}
},
{
key
:
'
handleRemoteStreamAdded
'
,
...
...
@@ -362,6 +362,12 @@ var Peer = function (_WildEmitter) {
};
return
sender
;
}
},
{
key
:
'
getStats
'
,
value
:
function
getStats
(
selector
)
{
// TODO: Use adapter.js to patch this across browsers
return
this
.
pc
.
pc
.
getStats
(
selector
);
}
}]);
return
Peer
;
...
...
src/liowebrtc.js
View file @
7e94603d
...
...
@@ -295,6 +295,9 @@ class LioWebRTC extends WildEmitter {
}
connectToRandomPeer
()
{
if
(
!
this
.
connection
)
return
;
this
.
getClients
((
err
,
clients
)
=>
{
const
ids
=
Object
.
keys
(
clients
).
filter
(
c
=>
!
(
this
.
unconnectivePeers
[
c
]
===
true
||
c
===
this
.
id
||
isNeighbor
(
this
.
id
,
c
)));
if
(
ids
.
length
)
{
...
...
@@ -344,6 +347,9 @@ class LioWebRTC extends WildEmitter {
}
disconnect
()
{
if
(
!
this
.
connection
)
return
;
this
.
connection
.
disconnect
();
delete
this
.
connection
;
}
...
...
@@ -502,7 +508,7 @@ class LioWebRTC extends WildEmitter {
if
(
type
!==
'
turnservers
'
&&
client
[
type
])
{
console
.
log
(
'
Connecting to random peer
'
,
peerId
)
let
peerCount
=
this
.
webrtc
.
getPeers
().
length
;
const
peers
=
self
.
webrtc
.
getPeers
(
peerId
,
type
);
const
peers
=
this
.
webrtc
.
getPeers
(
peerId
,
type
);
peers
.
forEach
((
p
)
=>
{
p
.
end
(
false
);
peerCount
--
;
...
...
@@ -518,7 +524,7 @@ class LioWebRTC extends WildEmitter {
offerToReceiveAudio
:
type
!==
'
screen
'
&&
!
this
.
config
.
dataOnly
&&
this
.
config
.
receiveMedia
.
offerToReceiveAudio
?
1
:
0
,
offerToReceiveVideo
:
!
this
.
config
.
dataOnly
&&
this
.
config
.
receiveMedia
.
offerToReceiveVideo
?
1
:
0
,
},
iceServers
:
self
.
webrtc
.
config
.
peerConnectionConfig
.
iceServers
.
concat
(
client
.
turnservers
),
iceServers
:
this
.
webrtc
.
config
.
peerConnectionConfig
.
iceServers
.
concat
(
client
.
turnservers
),
});
if
(
this
.
config
.
dataOnly
&&
this
.
config
.
constraints
.
maxPeers
>
0
)
{
this
.
sendPing
(
peer
,
peerId
,
true
);
...
...
src/peer.js
View file @
7e94603d
...
...
@@ -234,11 +234,11 @@ class Peer extends WildEmitter {
end
(
emitRemoval
=
true
)
{
if
(
this
.
closed
)
return
;
this
.
pc
.
close
();
this
.
handleStreamRemoved
(
emitRemoval
);
if
(
emitRemoval
)
{
this
.
parent
.
emit
(
'
removedPeer
'
,
this
);
}
this
.
pc
.
close
();
this
.
handleStreamRemoved
(
emitRemoval
);
}
handleRemoteStreamAdded
(
event
)
{
...
...
@@ -294,6 +294,11 @@ class Peer extends WildEmitter {
};
return
sender
;
}
getStats
(
selector
)
{
// TODO: Use adapter.js to patch this across browsers
return
this
.
pc
.
pc
.
getStats
(
selector
);
}
}
export
default
Peer
;
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