Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
galene
Commits
63e1a6f4
Commit
63e1a6f4
authored
Jan 11, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak relay-test.
parent
165c942d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
static/galene.js
static/galene.js
+19
-9
No files found.
static/galene.js
View file @
63e1a6f4
...
...
@@ -2060,7 +2060,14 @@ commands.wall = {
},
};
/**
* Test loopback through a TURN relay.
*
* @returns {Promise<number>}
*/
async
function
relayTest
()
{
if
(
!
serverConnection
)
throw
new
Error
(
'
not connected
'
);
let
conf
=
Object
.
assign
({},
serverConnection
.
rtcConfiguration
);
conf
.
iceTransportPolicy
=
'
relay
'
;
let
pc1
=
new
RTCPeerConnection
(
conf
);
...
...
@@ -2068,10 +2075,10 @@ async function relayTest() {
pc1
.
onicecandidate
=
e
=>
{
e
.
candidate
&&
pc2
.
addIceCandidate
(
e
.
candidate
);};
pc2
.
onicecandidate
=
e
=>
{
e
.
candidate
&&
pc1
.
addIceCandidate
(
e
.
candidate
);};
try
{
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
let
d1
=
pc1
.
createDataChannel
(
'
loopbackTest
'
);
d1
.
onopen
=
e
=>
{
d1
.
send
(
'
loopback
'
);
d1
.
send
(
Date
.
now
().
toString
()
);
};
let
offer
=
await
pc1
.
createOffer
();
...
...
@@ -2084,14 +2091,15 @@ async function relayTest() {
pc2
.
ondatachannel
=
e
=>
{
let
d2
=
e
.
channel
;
d2
.
onmessage
=
e
=>
{
if
(
e
.
data
===
'
loopback
'
)
resolve
();
let
t
=
parseInt
(
e
.
data
);
if
(
isNaN
(
t
))
reject
(
new
Error
(
'
corrupt data
'
));
else
re
ject
(
'
unexpected data
'
);
re
solve
(
Date
.
now
()
-
t
);
}
}
setTimeout
(()
=>
reject
(
'
timed out
'
),
5000
);
setTimeout
(()
=>
reject
(
new
Error
(
'
timeout
'
)
),
5000
);
})
}
finally
{
pc1
.
close
();
...
...
@@ -2104,12 +2112,14 @@ commands['relay-test'] = {
addToChatbox
(
null
,
null
,
null
,
Date
.
now
(),
false
,
null
,
`Relay test in progress...`
);
try
{
await
relayTest
();
let
s
=
Date
.
now
();
let
rtt
=
await
relayTest
();
let
e
=
Date
.
now
();
addToChatbox
(
null
,
null
,
null
,
Date
.
now
(),
false
,
null
,
`Relay test successful
.
`
);
`Relay test successful
in
${
e
-
s
}
ms, RTT
${
rtt
}
ms
`
);
}
catch
(
e
)
{
addToChatbox
(
null
,
null
,
null
,
Date
.
now
(),
false
,
null
,
'
Relay test failed:
'
+
e
);
`Relay test failed:
${
e
}
`
);
}
}
}
...
...
Write
Preview
Markdown
is supported
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