Split out status polling into own file
This commit is contained in:
parent
e3d84f37ac
commit
431c1a54e7
@ -155,12 +155,13 @@ GW TODO:
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="js/player/player.js"></script>
|
||||
<script src="js/status.js"></script>
|
||||
<script src="js/usercolors.js"></script>
|
||||
<script src="js/config.js"></script>
|
||||
<script src="js/utils.js"></script>
|
||||
<script src="js/message.js"></script>
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/player/airplay.js"></script>
|
||||
<script src="js/player/player.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -29,38 +29,6 @@ async function setupApp() {
|
||||
app.title = config.title;
|
||||
}
|
||||
|
||||
async function getStatus() {
|
||||
const url = "/status";
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const status = await response.json();
|
||||
|
||||
if (!app.isOnline && status.online) {
|
||||
// The stream was offline, but now it's online. Force start of playback after an arbitrary
|
||||
// delay to make sure the stream has actual data ready to go.
|
||||
setTimeout(function () {
|
||||
restartPlayer();
|
||||
}, 3000)
|
||||
|
||||
}
|
||||
|
||||
app.streamStatus = status.online
|
||||
? "Stream is online."
|
||||
: "Stream is offline."
|
||||
|
||||
app.viewerCount = status.viewerCount;
|
||||
app.sessionMaxViewerCount = status.sessionMaxViewerCount;
|
||||
app.overallMaxViewerCount = status.overallMaxViewerCount;
|
||||
app.isOnline = status.online;
|
||||
|
||||
} catch (e) {
|
||||
app.streamStatus = "Stream server is offline."
|
||||
app.viewerCount = 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var websocketReconnectTimer;
|
||||
function setupWebsocket() {
|
||||
clearTimeout(websocketReconnectTimer)
|
||||
|
31
webroot/js/status.js
Normal file
31
webroot/js/status.js
Normal file
@ -0,0 +1,31 @@
|
||||
async function getStatus() {
|
||||
const url = "/status";
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const status = await response.json();
|
||||
|
||||
if (!app.isOnline && status.online) {
|
||||
// The stream was offline, but now it's online. Force start of playback after an arbitrary
|
||||
// delay to make sure the stream has actual data ready to go.
|
||||
setTimeout(function () {
|
||||
restartPlayer();
|
||||
}, 3000)
|
||||
|
||||
}
|
||||
|
||||
app.streamStatus = status.online
|
||||
? "Stream is online."
|
||||
: "Stream is offline."
|
||||
|
||||
app.viewerCount = status.viewerCount;
|
||||
app.sessionMaxViewerCount = status.sessionMaxViewerCount;
|
||||
app.overallMaxViewerCount = status.overallMaxViewerCount;
|
||||
app.isOnline = status.online;
|
||||
|
||||
} catch (e) {
|
||||
app.streamStatus = "Stream server is offline."
|
||||
app.viewerCount = 0
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user