mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-26 00:33:12 +09:00
ws combinators now working
This commit is contained in:
1 parent
1ab3c49772
commit
7b661781f2
1 file changed
+12
-12
@@ -418,10 +418,11 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
|||||||
_.once(instanceManagement);
|
_.once(instanceManagement);
|
||||||
function instanceManagement() {
|
function instanceManagement() {
|
||||||
/* Open websocket connection to master */
|
/* Open websocket connection to master */
|
||||||
var socket = ioClient(config.masterIP+":"+config.masterPort);
|
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort);
|
||||||
socket.on("hello", function(){
|
socket.on("hello", data => {
|
||||||
|
console.log("SOCKET | registering slave!");
|
||||||
socket.emit("registerSlave", {
|
socket.emit("registerSlave", {
|
||||||
instanceID: config.instanceID,
|
instanceID: instanceconfig.unique,
|
||||||
});
|
});
|
||||||
setInterval(B=> socket.emit("heartbeat"), 10000);
|
setInterval(B=> socket.emit("heartbeat"), 10000);
|
||||||
});
|
});
|
||||||
@@ -825,8 +826,8 @@ function instanceManagement() {
|
|||||||
* Fetch combinator signals from the server
|
* Fetch combinator signals from the server
|
||||||
*/
|
*/
|
||||||
socket.on("processCombinatorSignal", circuitFrameWithMeta => {
|
socket.on("processCombinatorSignal", circuitFrameWithMeta => {
|
||||||
if(circuitFrameWithMeta && typeof circuitFrameWithMeta == "object" && circuitFrameWithMeta.frame && Array.isArray(circuitFrameWithMeta.frame) && objectOps.isJSON(circuitFrameWithMeta.frame)){
|
if(circuitFrameWithMeta && typeof circuitFrameWithMeta == "object" && circuitFrameWithMeta.frame && Array.isArray(circuitFrameWithMeta.frame)){
|
||||||
messageInterface("/silent-command remote.call('clusterio', 'recieveMany', '"+JSON.stringify(circuitFrameWithMeta.frame)+"')");
|
messageInterface("/silent-command remote.call('clusterio', 'receiveFrame', '"+JSON.stringify(circuitFrameWithMeta.frame)+"')");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// get outbound frames from file and send to master
|
// get outbound frames from file and send to master
|
||||||
@@ -841,14 +842,13 @@ function instanceManagement() {
|
|||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
txBufferClearCounter++;
|
txBufferClearCounter++;
|
||||||
fs.readFile(instancedirectory + "/script-output/txbuffer.txt", "utf-8", (err, signals) => {
|
fs.readFile(instancedirectory + "/script-output/txbuffer.txt", "utf-8", (err, signals) => {
|
||||||
//if(txBufferClearCounter > 500){
|
|
||||||
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "");
|
|
||||||
// txBufferClearCounter = 0;
|
|
||||||
//}
|
|
||||||
signals = signals.split("\n");
|
signals = signals.split("\n");
|
||||||
console.log(signals);
|
|
||||||
if (signals[0]) {
|
if (signals[0]) {
|
||||||
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "");
|
//if(txBufferClearCounter > 500){
|
||||||
|
fs.writeFileSync(instancedirectory + "/script-output/txbuffer.txt", "");
|
||||||
|
// txBufferClearCounter = 0;
|
||||||
|
//}
|
||||||
|
|
||||||
// loop through all our frames
|
// loop through all our frames
|
||||||
for (let i = 0; i < signals.length; i++) {
|
for (let i = 0; i < signals.length; i++) {
|
||||||
if (signals[i] && objectOps.isJSON(signals[i])) {
|
if (signals[i] && objectOps.isJSON(signals[i])) {
|
||||||
@@ -862,7 +862,7 @@ function instanceManagement() {
|
|||||||
// send to master using socket.io, opened at the top of instanceManagement()
|
// send to master using socket.io, opened at the top of instanceManagement()
|
||||||
socket.emit("combinatorSignal", doneframe);
|
socket.emit("combinatorSignal", doneframe);
|
||||||
} else {
|
} else {
|
||||||
console.log("Invalid jsony: "+signals[i])
|
// console.log("Invalid jsony: "+typeof signals[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user