use serverId in protocol instead of legacy info object
This commit is contained in:
@ -5,7 +5,7 @@ import io from 'socket.io-client'
|
||||
const app = new App()
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const socket = io.connect({
|
||||
const socket = io.connect('http://localhost:8080', {
|
||||
reconnect: true,
|
||||
reconnectDelay: 1000,
|
||||
reconnectionAttempts: 10
|
||||
@ -34,19 +34,22 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
let lastRowCounter = 0
|
||||
let controlsHTML = ''
|
||||
|
||||
Object.keys(data).sort().forEach(function (serverName) {
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(serverName)
|
||||
app.serverRegistry.getServerRegistrations()
|
||||
.map(serverRegistration => serverRegistration.data.name)
|
||||
.sort()
|
||||
.forEach(serverName => {
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(serverName)
|
||||
|
||||
controlsHTML += '<td>' +
|
||||
'<input type="checkbox" class="graph-control" minetrack-server-id="' + serverRegistration.serverId + '" ' + (serverRegistration.isVisible ? 'checked' : '') + '>' +
|
||||
' ' + serverName +
|
||||
'</input></td>'
|
||||
controlsHTML += '<td>' +
|
||||
'<input type="checkbox" class="graph-control" minetrack-server-id="' + serverRegistration.serverId + '" ' + (serverRegistration.isVisible ? 'checked' : '') + '>' +
|
||||
' ' + serverName +
|
||||
'</input></td>'
|
||||
|
||||
// Occasionally break table rows using a magic number
|
||||
if (++lastRowCounter % 6 === 0) {
|
||||
controlsHTML += '</tr><tr>'
|
||||
}
|
||||
})
|
||||
// Occasionally break table rows using a magic number
|
||||
if (++lastRowCounter % 6 === 0) {
|
||||
controlsHTML += '</tr><tr>'
|
||||
}
|
||||
})
|
||||
|
||||
// Apply generated HTML and show controls
|
||||
document.getElementById('big-graph-checkboxes').innerHTML = '<table><tr>' +
|
||||
@ -66,7 +69,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
return
|
||||
}
|
||||
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(data.name)
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(data.serverId)
|
||||
|
||||
if (serverRegistration) {
|
||||
app.graphDisplayManager.addGraphPoint(serverRegistration.serverId, data.timestamp, data.playerCount)
|
||||
@ -86,7 +89,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// The backend may send "update" events prior to receiving all "add" events
|
||||
// A server has only been added once it's ServerRegistration is defined
|
||||
// Checking undefined protects from this race condition
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(data.info.name)
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(data.serverId)
|
||||
|
||||
if (serverRegistration) {
|
||||
serverRegistration.updateServerStatus(data, false, app.publicConfig.minecraftVersions)
|
||||
@ -121,26 +124,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
app.handleSyncComplete()
|
||||
})
|
||||
|
||||
socket.on('updatePeak', function (data) {
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(data.name)
|
||||
|
||||
if (serverRegistration) {
|
||||
serverRegistration.updateServerPeak(data.timestamp, data.playerCount)
|
||||
}
|
||||
})
|
||||
|
||||
socket.on('peaks', function (data) {
|
||||
Object.keys(data).forEach(function (serverName) {
|
||||
const serverRegistration = app.serverRegistry.getServerRegistration(serverName)
|
||||
|
||||
if (serverRegistration) {
|
||||
const graphPeak = data[serverName]
|
||||
|
||||
serverRegistration.updateServerPeak(graphPeak.timestamp, graphPeak.playerCount)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.addEventListener('resize', function () {
|
||||
app.percentageBar.redraw()
|
||||
|
||||
|
Reference in New Issue
Block a user