mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 19:42:20 +00:00
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,
|
stream,
|
||||||
);
|
);
|
||||||
viewerCounter.regularUpdate(viewersCounterRefreshPeriod);
|
viewerCounter.regularUpdate(viewersCounterRefreshPeriod);
|
||||||
|
viewerCounter.refreshViewersCounter();
|
||||||
|
|
||||||
// Side widget toggler
|
// Side widget toggler
|
||||||
const sideWidgetToggle = document.getElementById("sideWidgetToggle");
|
const sideWidgetToggle = document.getElementById("sideWidgetToggle");
|
||||||
|
@ -17,10 +17,10 @@ export class ViewerCounter {
|
|||||||
* @param {Number} updatePeriod
|
* @param {Number} updatePeriod
|
||||||
*/
|
*/
|
||||||
regularUpdate(updatePeriod) {
|
regularUpdate(updatePeriod) {
|
||||||
setInterval(this._refreshViewersCounter, updatePeriod);
|
setInterval(() => this.refreshViewersCounter(), updatePeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
_refreshViewersCounter() {
|
refreshViewersCounter() {
|
||||||
fetch(this.url)
|
fetch(this.url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then((data) => this.element.innerText = data.ConnectedViewers)
|
.then((data) => this.element.innerText = data.ConnectedViewers)
|
||||||
|
@ -17,8 +17,8 @@ export class GsWebRTC {
|
|||||||
this.pc.addTransceiver("audio", { "direction": "sendrecv" });
|
this.pc.addTransceiver("audio", { "direction": "sendrecv" });
|
||||||
|
|
||||||
// Configure events
|
// Configure events
|
||||||
this.pc.oniceconnectionstatechange = this._onConnectionStateChange;
|
this.pc.oniceconnectionstatechange = () => this._onConnectionStateChange();
|
||||||
this.pc.ontrack = this._onTrack;
|
this.pc.ontrack = (e) => this._onTrack(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,11 +23,11 @@ export class GsWebSocket {
|
|||||||
});
|
});
|
||||||
this.socket.addEventListener("close", () => {
|
this.socket.addEventListener("close", () => {
|
||||||
console.log("WebSocket closed, retrying connection in 1s...");
|
console.log("WebSocket closed, retrying connection in 1s...");
|
||||||
setTimeout(this._open, 1000);
|
setTimeout(() => this._open(), 1000);
|
||||||
});
|
});
|
||||||
this.socket.addEventListener("error", () => {
|
this.socket.addEventListener("error", () => {
|
||||||
console.log("WebSocket errored, retrying connection in 1s...");
|
console.log("WebSocket errored, retrying connection in 1s...");
|
||||||
setTimeout(this._open, 1000);
|
setTimeout(() => this._open(), 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user