use serverId in protocol instead of legacy info object

This commit is contained in:
Nick Krecklow
2020-04-29 04:01:10 -05:00
parent 36c3e056c2
commit be92449d52
8 changed files with 59 additions and 93 deletions

View File

@ -107,8 +107,6 @@ class PingController {
handlePing (serverRegistration, resp, err, version) {
const timestamp = new Date().getTime()
this._app.server.broadcast('update', serverRegistration.getUpdate(timestamp, resp, err, version))
serverRegistration.addPing(timestamp, resp)
if (config.logToDatabase) {
@ -119,24 +117,14 @@ class PingController {
if (serverRegistration.addGraphPoint(resp !== undefined, playerCount, timestamp)) {
this._app.server.broadcast('updateHistoryGraph', {
name: serverRegistration.data.name,
serverId: serverRegistration.serverId,
playerCount: playerCount,
timestamp: timestamp
})
}
// Update calculated graph peak regardless if the graph is being updated
// This can cause a (harmless) desync between live and stored data, but it allows it to be more accurate for long surviving processes
if (serverRegistration.findNewGraphPeak()) {
const graphPeak = serverRegistration.getGraphPeak()
this._app.server.broadcast('updatePeak', {
name: serverRegistration.data.name,
playerCount: graphPeak.playerCount,
timestamp: graphPeak.timestamp
})
}
}
this._app.server.broadcast('update', serverRegistration.getUpdate(timestamp, resp, err, version))
}
}