Fix some undefined this in js classes
This commit is contained in:
parent
9d162b13ed
commit
e461c0b526
|
@ -58,6 +58,7 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
|
|||
stream,
|
||||
);
|
||||
viewerCounter.regularUpdate(viewersCounterRefreshPeriod);
|
||||
viewerCounter.refreshViewersCounter();
|
||||
|
||||
// Side widget toggler
|
||||
const sideWidgetToggle = document.getElementById("sideWidgetToggle");
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue