stat-frontend: Allow passing a URL to the stat producer

This commit is contained in:
Thibault Saunier 2021-12-03 20:56:15 +00:00 committed by Mathieu Duponchelle
parent da0a934307
commit d15c32e3e6
2 changed files with 12 additions and 1 deletions

View file

@ -14,3 +14,7 @@ Then navigate to `http://localhost:3000/`. Once consumers are connected
to the webrtc-sink-stats-server, they should be listed on the page, clicking
on any consumer will show a modal with plots for some of the most interesting
statistics.
The stat server can also be specified through the `remote-url` search parameter,
for example you can access a distant stat server with
`http://localhost:3000?remote-uri=my-remoye.com:72522`.

View file

@ -80,7 +80,14 @@
}
const fetchStats = () => {
ws = new WebSocket("ws://127.0.0.1:8484");
const urlParams = new URLSearchParams(window.location.search);
var remote_server = urlParams.get('remote-url');
if (!remote_server)
remote_server = "127.0.0.1:8484"
const ws_url = `ws://${remote_server}`;
console.info(`Logging to ${ws_url}`);
ws = new WebSocket(ws_url);
ws.onerror = () => {
websocketStatus = WebSocketStatus.Error