refactor: return flushed instead of callback

This commit is contained in:
cha0s 2019-05-04 12:42:40 -05:00
parent a66b6889f2
commit 40eb5867ee

View File

@ -23,11 +23,16 @@ export class EntityPacketSynchronizer {
}
flushPackets(flusher) {
for (const [entity, packets] of this.packetsToSynchronize.entries()) {
const flushed = new Map();
const it = this.packetsToSynchronize.entries();
for (let value = it.next(); !value.done; value = it.next()) {
const entity = value.value[0];
const packets = value.value[1];
const mergedPackets = this._mergePackets(packets);
flusher(entity, Array.from(mergedPackets.values()));
flushed.set(entity, mergedPackets);
}
this.packetsToSynchronize.clear();
return flushed;
}
_mergePackets(packets) {