Fix first-boot connection check.

This commit is contained in:
Cryptkeeper 2015-11-24 00:26:36 -06:00
parent 695e70f4c7
commit 4c3535a9d0

20
app.js

@ -89,7 +89,7 @@ server.start(function() {
// Track how many people are currently connected. // Track how many people are currently connected.
server.io.on('connect', function(client) { server.io.on('connect', function(client) {
// If we haven't sent out at least one round of pings, disconnect them for now. // If we haven't sent out at least one round of pings, disconnect them for now.
if (Object.keys(networkHistory) < config.servers.length) { if (Object.keys(networkHistory).length < config.servers.length) {
client.disconnect(); client.disconnect();
return; return;
@ -100,16 +100,18 @@ server.start(function() {
logger.log('info', 'Accepted connection: %s, total clients: %d', client.request.connection.remoteAddress, connectedClients); logger.log('info', 'Accepted connection: %s, total clients: %d', client.request.connection.remoteAddress, connectedClients);
// Remap our associative array into just an array. setTimeout(function() {
var networkHistoryKeys = Object.keys(networkHistory); // Send them our previous data, so they have somewhere to start.
client.emit('updateMojangServices', mojang.toMessage());
// Send each individually, this should look cleaner than waiting for one big array to transfer. // Remap our associative array into just an array.
for (var i = 0; i < networkHistoryKeys.length; i++) { var networkHistoryKeys = Object.keys(networkHistory);
client.emit('add', [networkHistory[networkHistoryKeys[i]]]);
}
// Send them our previous data, so they have somewhere to start. // Send each individually, this should look cleaner than waiting for one big array to transfer.
client.emit('updateMojangServices', mojang.toMessage()); for (var i = 0; i < networkHistoryKeys.length; i++) {
client.emit('add', [networkHistory[networkHistoryKeys[i]]]);
}
}, 1);
// Attach our listeners. // Attach our listeners.
client.on('disconnect', function(client) { client.on('disconnect', function(client) {