use serverId in protocol instead of legacy info object
This commit is contained in:
15
lib/app.js
15
lib/app.js
@ -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)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user