merge updateHistoryGraph behavior into update flag

This commit is contained in:
Nick Krecklow
2020-04-29 04:21:50 -05:00
parent 7d47e9b5f8
commit 7322b8dc82
3 changed files with 28 additions and 26 deletions

View File

@ -109,6 +109,8 @@ class PingController {
serverRegistration.addPing(timestamp, resp)
let updateHistoryGraph = false
if (config.logToDatabase) {
const playerCount = resp ? resp.players.online : 0
@ -116,15 +118,14 @@ class PingController {
this._app.database.insertPing(serverRegistration.data.ip, timestamp, playerCount)
if (serverRegistration.addGraphPoint(resp !== undefined, playerCount, timestamp)) {
this._app.server.broadcast('updateHistoryGraph', {
serverId: serverRegistration.serverId,
playerCount: playerCount,
timestamp: timestamp
})
updateHistoryGraph = true
}
}
this._app.server.broadcast('update', serverRegistration.getUpdate(timestamp, resp, err, version))
// Generate a combined update payload
// This includes any modified fields and flags used by the frontend
// This will not be cached and can contain live metadata
this._app.server.broadcast('update', serverRegistration.getUpdate(timestamp, resp, err, version, updateHistoryGraph))
}
}