mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
webrtc: fix Javascript/Browser demo client
This commit is contained in:
parent
79f930301f
commit
f2c9acb536
1 changed files with 25 additions and 11 deletions
|
@ -118,17 +118,17 @@
|
|||
var iceUsername = 'villas';
|
||||
var icePassword = 'villas';
|
||||
var iceUrls = [
|
||||
'stun:edgy.0l.de:3478',
|
||||
'turn:edgy.0l.de:3478?transport=udp',
|
||||
'turn:edgy.0l.de:3478?transport=tcp'
|
||||
'stun:stun.0l.de:3478',
|
||||
'turn:turn.0l.de:3478?transport=udp',
|
||||
'turn:turn.0l.de:3478?transport=tcp'
|
||||
];
|
||||
|
||||
// Functions
|
||||
|
||||
// Set things up, connect event listeners, etc.
|
||||
function startup() {
|
||||
log = document.getElementById('log'),
|
||||
logContainer = document.getElementById('log-container')
|
||||
log = document.getElementById('log');
|
||||
logContainer = document.getElementById('log-container');
|
||||
rewireLoggingToElement();
|
||||
|
||||
btnConnect = document.getElementById('connect');
|
||||
|
@ -151,6 +151,14 @@
|
|||
btnDisconnect.addEventListener('click', disconnectPeers, false);
|
||||
btnSend.addEventListener('click', sendMessage, false);
|
||||
|
||||
let queryParams = new URLSearchParams(window.location.search)
|
||||
let sessionNameQuery = queryParams.get('session_name');
|
||||
let autoConnect = queryParams.get('auto_connect');
|
||||
|
||||
if (sessionNameQuery !== null) {
|
||||
sessionName = sessionNameQuery;
|
||||
}
|
||||
|
||||
inpServer.onkeyup = (e) => {
|
||||
server = e.target.value;
|
||||
updateConfig();
|
||||
|
@ -183,6 +191,10 @@
|
|||
inpIceUrls.value = iceUrls;
|
||||
|
||||
updateConfig();
|
||||
|
||||
if (autoConnect !== null) {
|
||||
connectPeers();
|
||||
}
|
||||
}
|
||||
|
||||
function rewireLoggingToElement() {
|
||||
|
@ -219,15 +231,17 @@
|
|||
const isScrolledToBottom = logContainer.scrollHeight - logContainer.clientHeight <= logContainer.scrollTop + 1;
|
||||
log.appendChild(output);
|
||||
log.innerHTML += '<br>';
|
||||
if (isScrolledToBottom)
|
||||
if (isScrolledToBottom) {
|
||||
logContainer.scrollTop = logContainer.scrollHeight - logContainer.clientHeight;
|
||||
}
|
||||
|
||||
console['old' + name].apply(undefined, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
for (logger of['log', 'debug', 'warn', 'error', 'info'])
|
||||
for (logger of['log', 'debug', 'warn', 'error', 'info']) {
|
||||
fixLoggingFunc(logger);
|
||||
}
|
||||
}
|
||||
|
||||
function updateConfig() {
|
||||
|
@ -314,16 +328,16 @@
|
|||
|
||||
function handleIceCandidate(event) {
|
||||
if (event.candidate == null) {
|
||||
console.info('Candidate gathering completed')
|
||||
return
|
||||
console.info('Candidate gathering completed');
|
||||
return;
|
||||
}
|
||||
|
||||
console.info('New local ICE Candidate', event.candidate);
|
||||
|
||||
let msg = {
|
||||
candidate: event
|
||||
candidate: event.candidate.toJSON()
|
||||
};
|
||||
console.info('Sending signaling message', msg)
|
||||
console.info('Sending signaling message', msg);
|
||||
sc.send(JSON.stringify(msg));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue