mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Mod seperated from slave, node client.js download
This commit is contained in:
1 parent
c33ca4abec
commit
f589273c32
9 files changed
+244
-1930
No files matched your search
@@ -2,6 +2,7 @@ var fs = require('fs');
|
||||
var needle = require("needle");
|
||||
var child_process = require('child_process');
|
||||
var path = require('path')
|
||||
var syncRequest = require('sync-request');
|
||||
|
||||
// require config.json
|
||||
var config = require('./config');
|
||||
@@ -28,6 +29,9 @@ function getDirectories(srcpath) {
|
||||
if (!fs.existsSync("./instances/")) {
|
||||
fs.mkdirSync("instances");
|
||||
}
|
||||
if (!fs.existsSync("./sharedMods/")) {
|
||||
fs.mkdirSync("sharedMods");
|
||||
}
|
||||
var instance = process.argv[3];
|
||||
var instancedirectory = './instances/' + instance;
|
||||
var command = process.argv[2];
|
||||
@@ -37,6 +41,8 @@ if (!command || command == "help" || command == "--help") {
|
||||
console.error("node client.js start [instance name]")
|
||||
console.error("node client.js list")
|
||||
console.error("node client.js delete [instance]")
|
||||
console.error("To download the latest version of the Clusterio lua mod, do")
|
||||
console.error("node client.js download")
|
||||
process.exit(1)
|
||||
} else if (command == "list") {
|
||||
console.dir(getDirectories("./instances/"));
|
||||
@@ -53,6 +59,20 @@ if (!command || command == "help" || command == "--help") {
|
||||
console.error("Instance not found: " + process.argv[3]);
|
||||
process.exit(1)
|
||||
}
|
||||
} else if (command == "download") {
|
||||
console.log("Downloading mods...");
|
||||
// get JSON data about releases
|
||||
let res = syncRequest('GET', 'https://api.github.com/repos/Danielv123/factorioClusterioMod/releases', {"headers":{"User-Agent":"Fuck you for requiring user agents!"}});
|
||||
let url = JSON.parse(res.getBody())[0].assets[0].browser_download_url;
|
||||
let name = JSON.parse(res.getBody())[0].assets[0].name;
|
||||
if(url) {
|
||||
console.log(url);
|
||||
let out = fs.createWriteStream('sharedMods/' + name);
|
||||
needle.get(url).pipe(out).on('finish', function() {
|
||||
console.log("Downloaded " + name);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
} else if (command == "start" && typeof instance == "string" && instance != "/" && !fs.existsSync(instancedirectory)) {
|
||||
// if instance does not exist, create it
|
||||
console.log("Creating instance...")
|
||||
@@ -62,7 +82,7 @@ if (!command || command == "help" || command == "--help") {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/orders.txt", "")
|
||||
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "")
|
||||
fs.mkdirSync(instancedirectory + "/mods/")
|
||||
fs.symlinkSync('../../../clusterio_0.0.3', instancedirectory + "/mods/clusterio_0.0.3", 'junction')
|
||||
fs.symlinkSync('../../../sharedMods', instancedirectory + "/mods", 'junction')
|
||||
fs.writeFileSync(instancedirectory + "/config.ini", "[path]\r\n\
|
||||
read-data=__PATH__executable__/../../data\r\n\
|
||||
write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
@@ -103,245 +123,251 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
]
|
||||
)
|
||||
console.log("Instance created!")
|
||||
}
|
||||
|
||||
var instanceconfig = require(instancedirectory + '/config');
|
||||
|
||||
|
||||
process.on('SIGINT', function () {
|
||||
console.log("Caught interrupt signal");
|
||||
//serverprocess.stdin.write('/quit')
|
||||
});
|
||||
|
||||
|
||||
//var serverprocess = child_process.exec(commandline)
|
||||
var serverprocess = child_process.spawn(
|
||||
'./' + config.factorioDirectory + '/bin/x64/factorio', [
|
||||
'-c', instancedirectory + '/config.ini',
|
||||
'--start-server', instancedirectory + '/save.zip',
|
||||
'--rcon-port', instanceconfig.clientPort,
|
||||
'--rcon-password', instanceconfig.clientPassword,
|
||||
'--server-settings', instancedirectory + '/server-settings.json',
|
||||
'--port', instanceconfig.factorioPort
|
||||
], {
|
||||
'stdio': ['pipe', 'pipe', 'pipe']
|
||||
} else if (command == "start" && typeof instance == "string" && instance != "/" && !fs.existsSync(instancedirectory)) {
|
||||
// Exit if no instance specified (it should be, just a safeguard)
|
||||
if(instancedirectory != "./instances/undefined"){
|
||||
var instanceconfig = require(instancedirectory + '/config');
|
||||
} else {
|
||||
process.exit(1)
|
||||
}
|
||||
)
|
||||
|
||||
serverprocess.on('close', (code) => {
|
||||
console.log(`child process exited with code ${code}`);
|
||||
process.exit();
|
||||
});
|
||||
|
||||
serverprocess.stdout.on('data', (chunk) => {
|
||||
console.log('OUT: ' + chunk);
|
||||
})
|
||||
|
||||
serverprocess.stderr.on('data', (chunk) => {
|
||||
console.log('ERR: ' + chunk);
|
||||
})
|
||||
process.on('SIGINT', function () {
|
||||
console.log("Caught interrupt signal");
|
||||
//serverprocess.stdin.write('/quit')
|
||||
});
|
||||
|
||||
// connect us to the server with rcon
|
||||
// IP, port, password
|
||||
var Rcon = require('simple-rcon');
|
||||
var client = new Rcon({
|
||||
host: 'localhost',
|
||||
port: instanceconfig.clientPort,
|
||||
password: instanceconfig.clientPassword,
|
||||
timeout: 0
|
||||
});
|
||||
|
||||
// wait a few seconds to let the server finish starting before connecting rcon
|
||||
//TODO: catch '2.033 Info RemoteCommandProcessor.cpp:97: Starting RCON interface at port 35002' from stdout maybe?
|
||||
setTimeout(() => {
|
||||
client.connect();
|
||||
}, 5000);
|
||||
//var serverprocess = child_process.exec(commandline)
|
||||
var serverprocess = child_process.spawn(
|
||||
'./' + config.factorioDirectory + '/bin/x64/factorio', [
|
||||
'-c', instancedirectory + '/config.ini',
|
||||
'--start-server', instancedirectory + '/save.zip',
|
||||
'--rcon-port', instanceconfig.clientPort,
|
||||
'--rcon-password', instanceconfig.clientPassword,
|
||||
'--server-settings', instancedirectory + '/server-settings.json',
|
||||
'--port', instanceconfig.factorioPort
|
||||
], {
|
||||
'stdio': ['pipe', 'pipe', 'pipe']
|
||||
}
|
||||
)
|
||||
|
||||
client.on('authenticated', function () {
|
||||
console.log('Authenticated!');
|
||||
}).on('connected', function () {
|
||||
console.log('Connected!');
|
||||
getID();
|
||||
}).on('disconnected', function () {
|
||||
console.log('Disconnected!');
|
||||
// now reconnect
|
||||
client.connect();
|
||||
});
|
||||
serverprocess.on('close', (code) => {
|
||||
console.log(`child process exited with code ${code}`);
|
||||
process.exit();
|
||||
});
|
||||
|
||||
// set some globals
|
||||
confirmedOrders = [];
|
||||
lastSignalCheck = Date.now();
|
||||
serverprocess.stdout.on('data', (chunk) => {
|
||||
console.log('OUT: ' + chunk);
|
||||
})
|
||||
|
||||
// world IDs ------------------------------------------------------------------
|
||||
function getID() {
|
||||
var payload = {
|
||||
time: Date.now(),
|
||||
rconPort: instanceconfig.clientPort,
|
||||
rconPassword: instanceconfig.clientPassword,
|
||||
serverPort: instanceconfig.factorioPort,
|
||||
unique: instanceconfig.clientPassword.hashCode(),
|
||||
publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config
|
||||
serverprocess.stderr.on('data', (chunk) => {
|
||||
console.log('ERR: ' + chunk);
|
||||
})
|
||||
|
||||
// connect us to the server with rcon
|
||||
// IP, port, password
|
||||
var Rcon = require('simple-rcon');
|
||||
var client = new Rcon({
|
||||
host: 'localhost',
|
||||
port: instanceconfig.clientPort,
|
||||
password: instanceconfig.clientPassword,
|
||||
timeout: 0
|
||||
});
|
||||
|
||||
// wait a few seconds to let the server finish starting before connecting rcon
|
||||
//TODO: catch '2.033 Info RemoteCommandProcessor.cpp:97: Starting RCON interface at port 35002' from stdout maybe?
|
||||
setTimeout(() => {
|
||||
client.connect();
|
||||
}, 5000);
|
||||
|
||||
client.on('authenticated', function () {
|
||||
console.log('Authenticated!');
|
||||
}).on('connected', function () {
|
||||
console.log('Connected!');
|
||||
getID();
|
||||
}).on('disconnected', function () {
|
||||
console.log('Disconnected!');
|
||||
// now reconnect
|
||||
client.connect();
|
||||
});
|
||||
|
||||
// set some globals
|
||||
confirmedOrders = [];
|
||||
lastSignalCheck = Date.now();
|
||||
|
||||
// world IDs ------------------------------------------------------------------
|
||||
function getID() {
|
||||
var payload = {
|
||||
time: Date.now(),
|
||||
rconPort: instanceconfig.clientPort,
|
||||
rconPassword: instanceconfig.clientPassword,
|
||||
serverPort: instanceconfig.factorioPort,
|
||||
unique: instanceconfig.clientPassword.hashCode(),
|
||||
publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config
|
||||
}
|
||||
require('getmac').getMac(function (err, mac) {
|
||||
if (err) throw err
|
||||
payload.mac = mac
|
||||
console.log(payload)
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/getID', payload, function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
||||
console.log(response.body)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
require('getmac').getMac(function (err, mac) {
|
||||
if (err) throw err
|
||||
payload.mac = mac
|
||||
console.log(payload)
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/getID', payload, function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
||||
console.log(response.body)
|
||||
setInterval(getID, 10000)
|
||||
// provide items --------------------------------------------------------------
|
||||
// trigger when something happens to output.txt
|
||||
fs.watch(instancedirectory + "/script-output/output.txt", function (eventType, filename) {
|
||||
// get array of lines in file
|
||||
items = fs.readFileSync(instancedirectory + "/script-output/output.txt", "utf8").split("\n");
|
||||
// if you found anything, reset the file
|
||||
if (items[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/output.txt", "")
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
setInterval(getID, 10000)
|
||||
// provide items --------------------------------------------------------------
|
||||
// trigger when something happens to output.txt
|
||||
fs.watch(instancedirectory + "/script-output/output.txt", function (eventType, filename) {
|
||||
// get array of lines in file
|
||||
items = fs.readFileSync(instancedirectory + "/script-output/output.txt", "utf8").split("\n");
|
||||
// if you found anything, reset the file
|
||||
if (items[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/output.txt", "")
|
||||
}
|
||||
for (i = 0; i < items.length; i++) {
|
||||
if (items[i]) {
|
||||
g = items[i].split(" ");
|
||||
g[0] = g[0].replace("\u0000", "");
|
||||
// console.log("exporting " + JSON.stringify(g));
|
||||
// send our entity and count to the master for him to keep track of
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/place', {
|
||||
name: g[0],
|
||||
count: g[1]
|
||||
},
|
||||
function (err, resp, body) {
|
||||
// console.log(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
// request items --------------------------------------------------------------
|
||||
setInterval(function () {
|
||||
// get array of lines in file
|
||||
items = fs.readFileSync(instancedirectory + "/script-output/orders.txt", "utf8").split("\n");
|
||||
// if we actually got anything from the file, proceed and reset file
|
||||
if (items[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/orders.txt", "");
|
||||
// prepare a package of all our requested items in a more tranfer friendly format
|
||||
var preparedPackage = {};
|
||||
for (i = 0; i < items.length; i++) {
|
||||
(function (i) {
|
||||
if (items[i]) {
|
||||
items[i] = items[i].split(" ");
|
||||
items[i][0] = items[i][0].replace("\u0000", "");
|
||||
items[i][0] = items[i][0].replace(",", "");
|
||||
if (preparedPackage[items[i][0]]) {
|
||||
if (typeof Number(preparedPackage[items[i][0]].count) == "number" && typeof Number(items[i][1]) == "number") {
|
||||
preparedPackage[items[i][0]] = {
|
||||
"name": items[i][0],
|
||||
"count": Number(preparedPackage[items[i][0]].count) + Number(items[i][1])
|
||||
};
|
||||
if (items[i]) {
|
||||
g = items[i].split(" ");
|
||||
g[0] = g[0].replace("\u0000", "");
|
||||
// console.log("exporting " + JSON.stringify(g));
|
||||
// send our entity and count to the master for him to keep track of
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/place', {
|
||||
name: g[0],
|
||||
count: g[1]
|
||||
},
|
||||
function (err, resp, body) {
|
||||
// console.log(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
// request items --------------------------------------------------------------
|
||||
setInterval(function () {
|
||||
// get array of lines in file
|
||||
items = fs.readFileSync(instancedirectory + "/script-output/orders.txt", "utf8").split("\n");
|
||||
// if we actually got anything from the file, proceed and reset file
|
||||
if (items[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/orders.txt", "");
|
||||
// prepare a package of all our requested items in a more tranfer friendly format
|
||||
var preparedPackage = {};
|
||||
for (i = 0; i < items.length; i++) {
|
||||
(function (i) {
|
||||
if (items[i]) {
|
||||
items[i] = items[i].split(" ");
|
||||
items[i][0] = items[i][0].replace("\u0000", "");
|
||||
items[i][0] = items[i][0].replace(",", "");
|
||||
if (preparedPackage[items[i][0]]) {
|
||||
if (typeof Number(preparedPackage[items[i][0]].count) == "number" && typeof Number(items[i][1]) == "number") {
|
||||
preparedPackage[items[i][0]] = {
|
||||
"name": items[i][0],
|
||||
"count": Number(preparedPackage[items[i][0]].count) + Number(items[i][1])
|
||||
};
|
||||
} else if (typeof Number(items[i][1]) == "number") {
|
||||
preparedPackage[items[i][0]] = {
|
||||
"name": items[i][0],
|
||||
"count": Number(items[i][1])
|
||||
};
|
||||
}
|
||||
} else if (typeof Number(items[i][1]) == "number") {
|
||||
preparedPackage[items[i][0]] = {
|
||||
"name": items[i][0],
|
||||
"count": Number(items[i][1])
|
||||
};
|
||||
}
|
||||
} else if (typeof Number(items[i][1]) == "number") {
|
||||
preparedPackage[items[i][0]] = {
|
||||
"name": items[i][0],
|
||||
"count": Number(items[i][1])
|
||||
};
|
||||
}
|
||||
}
|
||||
})(i);
|
||||
}
|
||||
// request our items, one item at a time
|
||||
for (i = 0; i < Object.keys(preparedPackage).length; i++) {
|
||||
console.log(preparedPackage[Object.keys(preparedPackage)[i]])
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/remove', preparedPackage[Object.keys(preparedPackage)[i]], function (err, response, body) {
|
||||
if (response && response.body && typeof response.body == "object") {
|
||||
// buffer confirmed orders
|
||||
confirmedOrders[confirmedOrders.length] = {
|
||||
[response.body.name]: response.body.count
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// if we got some confirmed orders
|
||||
// console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
||||
sadas = JSON.stringify(confirmedOrders)
|
||||
confirmedOrders = [];
|
||||
// send our RCON command with whatever we got
|
||||
client.exec("/silent-command remote.call('clusterio', 'importMany', '" + sadas + "')");
|
||||
}
|
||||
}, 3000)
|
||||
// COMBINATOR SIGNALS ---------------------------------------------------------
|
||||
// get inventory from Master and RCON it to our slave
|
||||
setInterval(function () {
|
||||
needle.get(config.masterIP + ":" + config.masterPort + '/inventory', function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// Take the inventory we (hopefully) got and turn it into the format LUA accepts
|
||||
// console.log(response.body)
|
||||
var inventory = response.body;
|
||||
var inventoryFrame = {};
|
||||
for (i = 0; i < inventory.length; i++) {
|
||||
inventoryFrame[inventory[i].name] = Number(inventory[i].count);
|
||||
})(i);
|
||||
}
|
||||
inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000);
|
||||
console.log("RCONing inventory! " + JSON.stringify(inventoryFrame));
|
||||
client.exec("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')");
|
||||
}
|
||||
});
|
||||
}, 1000)
|
||||
// send any signals the slave has been told to send
|
||||
setInterval(function () {
|
||||
// Fetch combinator signals from the server
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/readSignal', {
|
||||
since: lastSignalCheck
|
||||
}, function (err, response, body) {
|
||||
if (response && response.body && typeof response.body == "object" && response.body[0]) {
|
||||
// Take the new combinator frames and compress them so we can use a single command
|
||||
frameset = [];
|
||||
for (i = 0; i < response.body.length; i++) {
|
||||
frameset[i] = response.body[i].frame;
|
||||
}
|
||||
// console.log(frameset);
|
||||
// Send all our compressed frames
|
||||
client.exec("/silent-command remote.call('clusterio', 'receiveMany', '" + JSON.stringify(frameset) + "')");
|
||||
}
|
||||
});
|
||||
// after fetching all the latest frames, we take a timestamp. During the next iteration, we fetch all frames submitted after this.
|
||||
lastSignalCheck = Date.now();
|
||||
|
||||
// get outbound frames from file and send to master
|
||||
// get array of lines in file, each line should correspond to a JSON encoded frame
|
||||
signals = fs.readFileSync(instancedirectory + "/script-output/txbuffer.txt", "utf8").split("\n");
|
||||
// if we actually got anything from the file, proceed and reset file
|
||||
if (signals[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "");
|
||||
// loop through all our frames
|
||||
for (i = 0; i < signals.length; i++) {
|
||||
(function (i) {
|
||||
if (signals[i]) {
|
||||
// signals[i] is a JSON array called a "frame" of signals. We timestamp it for storage on master
|
||||
// then we unpack and RCON in this.frame to the game later.
|
||||
framepart = JSON.parse(signals[i])
|
||||
doneframe = {
|
||||
time: Date.now(),
|
||||
frame: framepart, // thats our array of objects(single signals)
|
||||
}
|
||||
// console.log(doneframe)
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/setSignal', doneframe, function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
||||
// request our items, one item at a time
|
||||
for (i = 0; i < Object.keys(preparedPackage).length; i++) {
|
||||
console.log(preparedPackage[Object.keys(preparedPackage)[i]])
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/remove', preparedPackage[Object.keys(preparedPackage)[i]], function (err, response, body) {
|
||||
if (response && response.body && typeof response.body == "object") {
|
||||
// buffer confirmed orders
|
||||
confirmedOrders[confirmedOrders.length] = {
|
||||
[response.body.name]: response.body.count
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})(i);
|
||||
// if we got some confirmed orders
|
||||
// console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
||||
sadas = JSON.stringify(confirmedOrders)
|
||||
confirmedOrders = [];
|
||||
// send our RCON command with whatever we got
|
||||
client.exec("/silent-command remote.call('clusterio', 'importMany', '" + sadas + "')");
|
||||
}
|
||||
}, 3000)
|
||||
// COMBINATOR SIGNALS ---------------------------------------------------------
|
||||
// get inventory from Master and RCON it to our slave
|
||||
setInterval(function () {
|
||||
needle.get(config.masterIP + ":" + config.masterPort + '/inventory', function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// Take the inventory we (hopefully) got and turn it into the format LUA accepts
|
||||
// console.log(response.body)
|
||||
var inventory = response.body;
|
||||
var inventoryFrame = {};
|
||||
for (i = 0; i < inventory.length; i++) {
|
||||
inventoryFrame[inventory[i].name] = Number(inventory[i].count);
|
||||
}
|
||||
inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000);
|
||||
console.log("RCONing inventory! " + JSON.stringify(inventoryFrame));
|
||||
client.exec("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')");
|
||||
}
|
||||
});
|
||||
}, 1000)
|
||||
// send any signals the slave has been told to send
|
||||
setInterval(function () {
|
||||
// Fetch combinator signals from the server
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/readSignal', {
|
||||
since: lastSignalCheck
|
||||
}, function (err, response, body) {
|
||||
if (response && response.body && typeof response.body == "object" && response.body[0]) {
|
||||
// Take the new combinator frames and compress them so we can use a single command
|
||||
frameset = [];
|
||||
for (i = 0; i < response.body.length; i++) {
|
||||
frameset[i] = response.body[i].frame;
|
||||
}
|
||||
// console.log(frameset);
|
||||
// Send all our compressed frames
|
||||
client.exec("/silent-command remote.call('clusterio', 'receiveMany', '" + JSON.stringify(frameset) + "')");
|
||||
}
|
||||
});
|
||||
// after fetching all the latest frames, we take a timestamp. During the next iteration, we fetch all frames submitted after this.
|
||||
lastSignalCheck = Date.now();
|
||||
|
||||
// get outbound frames from file and send to master
|
||||
// get array of lines in file, each line should correspond to a JSON encoded frame
|
||||
signals = fs.readFileSync(instancedirectory + "/script-output/txbuffer.txt", "utf8").split("\n");
|
||||
// if we actually got anything from the file, proceed and reset file
|
||||
if (signals[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "");
|
||||
// loop through all our frames
|
||||
for (i = 0; i < signals.length; i++) {
|
||||
(function (i) {
|
||||
if (signals[i]) {
|
||||
// signals[i] is a JSON array called a "frame" of signals. We timestamp it for storage on master
|
||||
// then we unpack and RCON in this.frame to the game later.
|
||||
framepart = JSON.parse(signals[i])
|
||||
doneframe = {
|
||||
time: Date.now(),
|
||||
frame: framepart, // thats our array of objects(single signals)
|
||||
}
|
||||
// console.log(doneframe)
|
||||
needle.post(config.masterIP + ":" + config.masterPort + '/setSignal', doneframe, function (err, response, body) {
|
||||
if (response && response.body) {
|
||||
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
||||
}
|
||||
});
|
||||
}
|
||||
})(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
}, 1000)
|
||||
} // END OF INSTANCE START ---------------------------------------------------------------------
|
||||
|
||||
// simple string hasher
|
||||
String.prototype.hashCode = function () {
|
||||
|
||||
Reference in new issue
Block a user