mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
#61 start of map store/retrieve, communication channel using websockets
This commit is contained in:
1 parent
2bcacb2513
commit
7ece1af073
9 files changed
+422
-4
No files matched your search
@@ -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', () => {
|
||||
|
||||
Reference in new issue
Block a user