mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2024-11-14 00:17:55 +01:00
create box data based on local ip
This commit is contained in:
parent
e874cbf012
commit
5b7f8300bd
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user