create box data based on local ip

This commit is contained in:
casperlamboo 2018-01-25 17:27:59 +01:00
parent e874cbf012
commit 5b7f8300bd
2 changed files with 6 additions and 8 deletions

View File

@ -9,12 +9,12 @@ import SystemAPI from './api/system.js';
import UpdateAPI from './api/update.js';
export default class Doodle3DBox extends EventDispatcher {
constructor(boxData) {
constructor(localip) {
super();
this.boxData = boxData;
this.localip = localip;
this.api = `http://${boxData.localip}/d3dapi/`;
this.api = `http://${localip}/d3dapi/`;
this.alive = false;
this.autoUpdate = false;

View File

@ -1,4 +1,3 @@
import Doodle3DBox from './doodle3dbox.js';
import EventDispatcher from 'eventdispatcher.js';
import { sleep, parseFetch } from './utils.js';
@ -47,16 +46,15 @@ export default class Doodle3DManager extends EventDispatcher {
if (this.checkNonServerBoxes) boxes = boxes.concat(this.nonServerBoxes);
const knownIPsClient = this.boxes.map(box => box.boxData.localip);
const knownIPsClient = this.boxes.map(box => box.localip);
const knownIPsServer = boxes.map(box => box.localip);
const newBoxes = boxes.filter(box => knownIPsClient.indexOf(box.localip) === -1);
const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.boxData.localip) === -1);
const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.localip) === -1);
let changed = false;
for (const boxData of newBoxes) {
const box = new Doodle3DBox(boxData);
this._addBox(box);
this._addBox(boxData);
changed = true;
}