1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 10:22:19 +00:00

Fix some undefined this in js classes

This commit is contained in:
Alexandre Iooss 2020-10-21 22:38:36 +02:00
parent 9d162b13ed
commit e461c0b526
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
4 changed files with 7 additions and 6 deletions

View File

@ -58,6 +58,7 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
stream,
);
viewerCounter.regularUpdate(viewersCounterRefreshPeriod);
viewerCounter.refreshViewersCounter();
// Side widget toggler
const sideWidgetToggle = document.getElementById("sideWidgetToggle");

View File

@ -17,10 +17,10 @@ export class ViewerCounter {
* @param {Number} updatePeriod
*/
regularUpdate(updatePeriod) {
setInterval(this._refreshViewersCounter, updatePeriod);
setInterval(() => this.refreshViewersCounter(), updatePeriod);
}
_refreshViewersCounter() {
refreshViewersCounter() {
fetch(this.url)
.then(response => response.json())
.then((data) => this.element.innerText = data.ConnectedViewers)

View File

@ -17,8 +17,8 @@ export class GsWebRTC {
this.pc.addTransceiver("audio", { "direction": "sendrecv" });
// Configure events
this.pc.oniceconnectionstatechange = this._onConnectionStateChange;
this.pc.ontrack = this._onTrack;
this.pc.oniceconnectionstatechange = () => this._onConnectionStateChange();
this.pc.ontrack = (e) => this._onTrack(e);
}
/**

View File

@ -23,11 +23,11 @@ export class GsWebSocket {
});
this.socket.addEventListener("close", () => {
console.log("WebSocket closed, retrying connection in 1s...");
setTimeout(this._open, 1000);
setTimeout(() => this._open(), 1000);
});
this.socket.addEventListener("error", () => {
console.log("WebSocket errored, retrying connection in 1s...");
setTimeout(this._open, 1000);
setTimeout(() => this._open(), 1000);
});
}