#61 start of map store/retrieve, communication channel using websockets

This commit is contained in:
Danielv123 committed 2017-11-21 11:06:57 +01:00
1 parent 2bcacb2513
commit 7ece1af073
9 files changed
+422 -4

No files matched your search

+11 -1
View File
@@ -1,10 +1,13 @@
const needle = require("needle");
const moduleConfig = require("./config");
const io = require("socket.io");
const moduleConfig = require("./config"); // not to be confused with clusterio config. This config is private to this plugin.
console.log("/silent-command game.print('"+moduleConfig.name+" version "+moduleConfig.version+" enabled')");
/*setInterval(function(){
console.log("/silent-command game.write_file('"+moduleConfig.scriptOutputFileSubscription+"', game.tick, true, 0)");
},1000);*/
var config = {};
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
@@ -17,6 +20,8 @@ process.stdin.on('readable', () => {
data.shift();data.shift();data.shift();
if(data && data[0] == undefined){
// this position is now empty, delete whatever was there from DB
console.log("empty: ")
console.log(chunk)
}
data.forEach(entity => {
let name = entity.split(" ")[0];
@@ -27,6 +32,11 @@ process.stdin.on('readable', () => {
} else {
// config is the same config as client.js and master.js uses
config = JSON.parse(chunk);
// socket should be a global
socket = io.connect("http://"+config.masterIP+":"+config.masterPort);
socket.on("hello", data => {
socket.emit("registerSlaveMapper", {instanceID: config.unique});
});
}
});
process.stdin.on('end', () => {