diff --git a/packages/core/src/traits/informed.js b/packages/core/src/traits/informed.js index bdb04d4..a2d7e26 100644 --- a/packages/core/src/traits/informed.js +++ b/packages/core/src/traits/informed.js @@ -44,14 +44,7 @@ export default (flecks) => { this.$$synchronizer.cleanPackets(); }, - inform: async (socket) => { - if (socket) { - const packets = this.$$synchronizer.packetsFor(this.entity); - if (packets.length > 0) { - await socket.send(['Bundle', packets]); - } - } - }, + informedPackets: () => this.$$synchronizer.packetsFor(this.entity), startInformingAbout: (synchronized) => { this.$$synchronizer.startSynchronizing(synchronized); diff --git a/packages/universe/src/server/universe/index.js b/packages/universe/src/server/universe/index.js index c51ffe1..2d090a8 100644 --- a/packages/universe/src/server/universe/index.js +++ b/packages/universe/src/server/universe/index.js @@ -102,13 +102,16 @@ export default class Universe { async inform() { for (let i = 0; i < this.$$players.length; ++i) { - this.$$players[i].inform(); + const packets = this.$$players[i].entity.informedPackets(); + if (packets.length > 0) { + this.$$players[i].socket.send(['Bundle', packets]); + } } for (let i = 0; i < this.$$roomsFlat.length; i++) { this.$$roomsFlat[i].cleanPackets(); } for (let i = 0; i < this.$$players.length; ++i) { - this.$$players[i].cleanInformingPackets(); + this.$$players[i].entity.cleanInformingPackets(); } } @@ -166,7 +169,7 @@ export default class Universe { removePlayer(player) { const {entity} = player; const room = this.room(entity.currentRoom); - entity.stopInforming(room); + entity.stopInformingAbout(room); room.removeEntity(entity); const index = this.$$players.indexOf(player); if (-1 !== index) { diff --git a/packages/universe/src/server/universe/player.js b/packages/universe/src/server/universe/player.js index 3035fd9..c731813 100644 --- a/packages/universe/src/server/universe/player.js +++ b/packages/universe/src/server/universe/player.js @@ -20,12 +20,4 @@ export default class Player extends decorate(Class) { socket.once('disconnect', emitRemove); } - cleanInformingPackets() { - this.entity.cleanInformingPackets(); - } - - inform() { - this.entity.inform(this.socket); - } - }