Fixed crash when master was not there and we still got some sort of response

This commit is contained in:
Danielv123 committed 2018-04-27 06:22:32 +02:00
1 parent ce0deef83b
commit 1b00fbb328
1 file changed
+3 -3
+3 -3
View File
@@ -847,9 +847,6 @@ function instanceManagement() {
if(Buffer.isBuffer(response.body)) {console.log(response.body.toString("utf-8")); throw new Error();} // We are probably contacting the wrong webserver if(Buffer.isBuffer(response.body)) {console.log(response.body.toString("utf-8")); throw new Error();} // We are probably contacting the wrong webserver
try { try {
var inventory = JSON.parse(response.body); var inventory = JSON.parse(response.body);
} catch (e){
console.log(e);
}
var inventoryFrame = {}; var inventoryFrame = {};
for (let i = 0; i < inventory.length; i++) { for (let i = 0; i < inventory.length; i++) {
inventoryFrame[inventory[i].name] = Number(inventory[i].count); inventoryFrame[inventory[i].name] = Number(inventory[i].count);
@@ -860,6 +857,9 @@ function instanceManagement() {
inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000); inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000);
// console.log("RCONing inventory! " + JSON.stringify(inventoryFrame)); // console.log("RCONing inventory! " + JSON.stringify(inventoryFrame));
messageInterface("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')"); messageInterface("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')");
} catch (e){
console.log(e);
}
} }
}); });
}, 1000); }, 1000);