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

@ -39,24 +39,11 @@ class App {
client.on('requestHistoryGraph', () => {
// Send historical graphData built from all serverRegistrations
const graphData = {}
const graphPeaks = {}
this.serverRegistrations.forEach((serverRegistration) => {
graphData[serverRegistration.data.name] = serverRegistration.graphData
// Send current peak, if any
const graphPeak = serverRegistration.getGraphPeak()
if (graphPeak) {
graphPeaks[serverRegistration.data.name] = graphPeak
}
graphData[serverRegistration.serverId] = serverRegistration.graphData
})
// Send current peaks, if any
// Emit peaks first since graphData may take a while to receive
if (Object.keys(graphPeaks).length > 0) {
client.emit('peaks', graphPeaks)
}
client.emit('historyGraph', graphData)
})
}