mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
#61 added webpage to master, some more plugin work
This commit is contained in:
1 parent
227ac87018
commit
ffe2df55c4
3 files changed
+23
-1
No files matched your search
@@ -75,6 +75,16 @@ describe('Master server endpoint testing', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("sends some HTML when accessing /remoteMap",function(done){
|
||||||
|
this.timeout(6000);
|
||||||
|
request(app).get("/remoteMap").end(function(err,res){
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
validateHTML(res.text).then(result => {
|
||||||
|
assert(result.messages.length === 0, "there are HTML errors on the page, please fix: "+JSON.stringify(result.messages));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
let persistentMaster = request(app);
|
let persistentMaster = request(app);
|
||||||
describe("#POST /api/place", function(){
|
describe("#POST /api/place", function(){
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ process.stdin.on('readable', () => {
|
|||||||
var chunk = process.stdin.read();
|
var chunk = process.stdin.read();
|
||||||
// console.log(chunk)
|
// console.log(chunk)
|
||||||
if (chunk !== null && isNaN(chunk) && config && isJson(chunk) && !JSON.parse(chunk).factorioPort){
|
if (chunk !== null && isNaN(chunk) && config && isJson(chunk) && !JSON.parse(chunk).factorioPort){
|
||||||
|
|
||||||
let inventory = JSON.parse(chunk)
|
let inventory = JSON.parse(chunk)
|
||||||
// process inventory of players and ask master for more stuff
|
// process inventory of players and ask master for more stuff
|
||||||
functions.handleInventory(inventory, config, console.log);
|
functions.handleInventory(inventory, config, console.log);
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
const needle = require("needle");
|
const needle = require("needle");
|
||||||
const io = require("socket.io");
|
const io = require("socket.io");
|
||||||
|
|
||||||
|
const chunkStore = require("./../../lib/chunkStore.js");
|
||||||
|
|
||||||
const moduleConfig = require("./config"); // not to be confused with clusterio config. This config is private to this plugin.
|
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')");
|
console.log("/silent-command game.print('"+moduleConfig.name+" version "+moduleConfig.version+" enabled')");
|
||||||
|
|
||||||
|
// initialize chunk database
|
||||||
|
const chunkMap = new chunkStore(config.unique, 64, "./chunkStore/"+config.unique);
|
||||||
|
|
||||||
/*setInterval(function(){
|
/*setInterval(function(){
|
||||||
console.log("/silent-command game.write_file('"+moduleConfig.scriptOutputFileSubscription+"', game.tick, true, 0)");
|
console.log("/silent-command game.write_file('"+moduleConfig.scriptOutputFileSubscription+"', game.tick, true, 0)");
|
||||||
},1000);*/
|
},1000);*/
|
||||||
@@ -14,6 +19,7 @@ process.stdin.on('readable', () => {
|
|||||||
var chunk = process.stdin.read();
|
var chunk = process.stdin.read();
|
||||||
if (chunk !== null && !isNaN(chunk) && !chunk.includes("objects")){
|
if (chunk !== null && !isNaN(chunk) && !chunk.includes("objects")){
|
||||||
console.log(chunk);
|
console.log(chunk);
|
||||||
|
throw chunk;
|
||||||
// objects -29,-35;-28,-34: ,inserter -28.5 -34.5
|
// objects -29,-35;-28,-34: ,inserter -28.5 -34.5
|
||||||
|
|
||||||
let data = chunk.split(",");
|
let data = chunk.split(",");
|
||||||
@@ -27,11 +33,18 @@ process.stdin.on('readable', () => {
|
|||||||
let name = entity.split(" ")[0];
|
let name = entity.split(" ")[0];
|
||||||
let xPos = entity.split(" ")[1];
|
let xPos = entity.split(" ")[1];
|
||||||
let yPos = entity.split(" ")[2];
|
let yPos = entity.split(" ")[2];
|
||||||
|
if(xPos && yPos && name){
|
||||||
|
chunkMap.setEntity(xPos, yPos, name).then(chunk => {
|
||||||
|
console.log("Added "+name+" to chunk "+chunk.position.x+", "+chunk.position.y);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// config is the same config as client.js and master.js uses
|
// config is the same config as client.js and master.js uses
|
||||||
config = JSON.parse(chunk);
|
config = JSON.parse(chunk);
|
||||||
|
|
||||||
|
// set up websocket communication and handle requests from web interface users (which are going through master)
|
||||||
// socket should be a global
|
// socket should be a global
|
||||||
socket = io.connect("http://"+config.masterIP+":"+config.masterPort);
|
socket = io.connect("http://"+config.masterIP+":"+config.masterPort);
|
||||||
socket.on("hello", data => {
|
socket.on("hello", data => {
|
||||||
|
|||||||
Reference in new issue
Block a user