send playerCount in payload directly instead of nesting into legacy data structure
This commit is contained in:
parent
04d94a9461
commit
320dc3c2fb
@ -119,7 +119,7 @@ export class App {
|
|||||||
// Set initial playerCount to the payload's value
|
// Set initial playerCount to the payload's value
|
||||||
// This will always exist since it is explicitly generated by the backend
|
// This will always exist since it is explicitly generated by the backend
|
||||||
// This is used for any post-add rendering of things like the percentageBar
|
// This is used for any post-add rendering of things like the percentageBar
|
||||||
serverRegistration.playerCount = payload.result.players.online
|
serverRegistration.playerCount = payload.playerCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the plot instance internally with the restructured and cleaned data
|
// Create the plot instance internally with the restructured and cleaned data
|
||||||
|
@ -105,8 +105,8 @@ export class ServerRegistration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePing (payload, timestamp) {
|
handlePing (payload, timestamp) {
|
||||||
if (payload.result) {
|
if (typeof payload.playerCount !== 'undefined') {
|
||||||
this.playerCount = payload.result.players.online
|
this.playerCount = payload.playerCount
|
||||||
|
|
||||||
// Only update graph for successful pings
|
// Only update graph for successful pings
|
||||||
// This intentionally pauses the server graph when pings begin to fail
|
// This intentionally pauses the server graph when pings begin to fail
|
||||||
@ -200,12 +200,12 @@ export class ServerRegistration {
|
|||||||
errorElement.style.display = 'block'
|
errorElement.style.display = 'block'
|
||||||
|
|
||||||
errorElement.innerText = ping.error.message
|
errorElement.innerText = ping.error.message
|
||||||
} else if (ping.result) {
|
} else if (typeof ping.playerCount !== 'undefined') {
|
||||||
// Ensure the player-count element is visible and hide the error element
|
// Ensure the player-count element is visible and hide the error element
|
||||||
playerCountLabelElement.style.display = 'block'
|
playerCountLabelElement.style.display = 'block'
|
||||||
errorElement.style.display = 'none'
|
errorElement.style.display = 'none'
|
||||||
|
|
||||||
document.getElementById('player-count-value_' + this.serverId).innerText = formatNumber(ping.result.players.online)
|
document.getElementById('player-count-value_' + this.serverId).innerText = formatNumber(ping.playerCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// An updated favicon has been sent, update the src
|
// An updated favicon has been sent, update the src
|
||||||
|
@ -101,7 +101,7 @@ export class SocketManager {
|
|||||||
// Skip any incoming updates if the graph is disabled
|
// Skip any incoming updates if the graph is disabled
|
||||||
if (serverUpdate.updateHistoryGraph && this._app.graphDisplayManager.isVisible) {
|
if (serverUpdate.updateHistoryGraph && this._app.graphDisplayManager.isVisible) {
|
||||||
// Update may not be successful, safely append 0 points
|
// Update may not be successful, safely append 0 points
|
||||||
const playerCount = serverUpdate.result ? serverUpdate.result.players.online : 0
|
const playerCount = serverUpdate.playerCount || 0
|
||||||
|
|
||||||
this._app.graphDisplayManager.addGraphPoint(serverRegistration.serverId, payload.timestamp, playerCount)
|
this._app.graphDisplayManager.addGraphPoint(serverRegistration.serverId, payload.timestamp, playerCount)
|
||||||
|
|
||||||
|
@ -70,9 +70,7 @@ class ServerRegistration {
|
|||||||
|
|
||||||
// Append a result object
|
// Append a result object
|
||||||
// This filters out unwanted data from resp
|
// This filters out unwanted data from resp
|
||||||
update.result = {
|
update.playerCount = resp.players.online
|
||||||
players: resp.players
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.logToDatabase) {
|
if (config.logToDatabase) {
|
||||||
// Update calculated graph peak regardless if the graph is being updated
|
// Update calculated graph peak regardless if the graph is being updated
|
||||||
@ -115,11 +113,7 @@ class ServerRegistration {
|
|||||||
// Assume the ping was a success and define result
|
// Assume the ping was a success and define result
|
||||||
// pingHistory does not keep error references, so its impossible to detect if this is an error
|
// pingHistory does not keep error references, so its impossible to detect if this is an error
|
||||||
// It is also pointless to store that data since it will be short lived
|
// It is also pointless to store that data since it will be short lived
|
||||||
payload.result = {
|
payload.playerCount = this._pingHistory[this._pingHistory.length - 1]
|
||||||
players: {
|
|
||||||
online: this._pingHistory[this._pingHistory.length - 1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a copy of pingHistory
|
// Send a copy of pingHistory
|
||||||
// Include the last value even though it is contained within payload
|
// Include the last value even though it is contained within payload
|
||||||
|
Loading…
Reference in New Issue
Block a user