centralize shift behavior into TimeTracker func
This commit is contained in:
@ -26,23 +26,13 @@ class ServerRegistration {
|
||||
const playerCount = resp ? resp.players.online : null
|
||||
|
||||
// Store into in-memory ping data
|
||||
this._pingHistory.push(playerCount)
|
||||
|
||||
// Trim pingHistory to avoid memory leaks
|
||||
if (this._pingHistory.length > TimeTracker.getMaxServerGraphDataLength()) {
|
||||
this._pingHistory.shift()
|
||||
}
|
||||
TimeTracker.pushAndShift(this._pingHistory, playerCount, TimeTracker.getMaxServerGraphDataLength())
|
||||
|
||||
// Only notify the frontend to append to the historical graph
|
||||
// if both the graphing behavior is enabled and the backend agrees
|
||||
// that the ping is eligible for addition
|
||||
if (updateHistoryGraph) {
|
||||
this.graphData.push(playerCount)
|
||||
|
||||
// Trim old graphPoints according to #getMaxGraphDataLength
|
||||
if (this.graphData.length > TimeTracker.getMaxGraphDataLength()) {
|
||||
this.graphData.shift()
|
||||
}
|
||||
TimeTracker.pushAndShift(this.graphData, playerCount, TimeTracker.getMaxGraphDataLength())
|
||||
}
|
||||
|
||||
// Delegate out update payload generation
|
||||
|
Reference in New Issue
Block a user