From 5b7f8300bd1c12629a70318e6700952a38626590 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Thu, 25 Jan 2018 17:27:59 +0100 Subject: [PATCH] create box data based on local ip --- src/doodle3dbox.js | 6 +++--- src/doodle3dmanager.js | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/doodle3dbox.js b/src/doodle3dbox.js index 150cf5d..fad1a3b 100644 --- a/src/doodle3dbox.js +++ b/src/doodle3dbox.js @@ -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; diff --git a/src/doodle3dmanager.js b/src/doodle3dmanager.js index 05e13ae..be6c7ba 100644 --- a/src/doodle3dmanager.js +++ b/src/doodle3dmanager.js @@ -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; }