Fix missing servers when refreshing too early

This commit is contained in:
Cryptkeeper 2016-02-06 18:36:51 -06:00
parent 798dda8f12
commit 584d7374df

21
app.js

@ -170,9 +170,28 @@ function startServices() {
networkHistoryKeys.sort(); networkHistoryKeys.sort();
// Send each individually, this should look cleaner than waiting for one big array to transfer. // Send each individually, this should look cleaner than waiting for one big array to transfer.
for (var i = 0; i < networkHistoryKeys.length; i++) { for (var i = 0; i < servers.length; i++) {
var server = servers[i];
if (!(server.name in networkHistory) || networkHistory[server.name].length < 1) {
// This server hasn't been ping'd yet. Send a hacky placeholder.
client.emit('add', [[{
error: {
description: 'Waiting'
},
result: null,
timestamp: util.getCurrentTimeMs(),
info: {
ip: server.ip,
port: server.port,
type: server.type,
name: server.name
}
}]]);
} else {
client.emit('add', [networkHistory[networkHistoryKeys[i]]]); client.emit('add', [networkHistory[networkHistoryKeys[i]]]);
} }
}
}); });
}); });