added boxes changed event

This commit is contained in:
casperlamboo 2016-04-21 15:17:38 +02:00
parent 65088708bd
commit 50167a686a
1 changed files with 9 additions and 1 deletions

View File

@ -58,14 +58,22 @@ export default class Doodle3DManager extends EventDispatcher {
const newBoxes = boxes.filter(box => knownIPsClient.indexOf(box.localip) === -1);
const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.boxData.localip) === -1);
let changed = false;
for (const boxData of newBoxes) {
const box = new Doodle3DAPI(boxData);
this._addBox(box);
changed = true;
}
for (const box of removedBoxes) {
this._removeBox(box);
changed = true;
}
if (changed) {
this.dispatchEvent({ type: 'boxeschanged', boxes: this.boxes });
}
}