refactor: let sync handle info embed
This commit is contained in:
parent
dd0f4da9ad
commit
4340be5e2d
|
@ -59,16 +59,9 @@ export class ServerSynchronizer {
|
|||
payload.push(synchronized.destroyPacket(informed));
|
||||
}
|
||||
else {
|
||||
const id = synchronized.synchronizationId();
|
||||
const type = idFromSynchronized(synchronized.constructor);
|
||||
const packets = synchronized.packetsFor(informed);
|
||||
for (let j = 0; j < packets.length; j++) {
|
||||
const packet = packets[j];
|
||||
packet.data.synchronized = {
|
||||
id,
|
||||
type,
|
||||
};
|
||||
payload.push(packet);
|
||||
payload.push(packets[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,12 @@ export function SynchronizedMixin(Superclass) {
|
|||
if (!Array.isArray(packets)) {
|
||||
packets = [packets];
|
||||
}
|
||||
// Embed synchronization info.
|
||||
const id = this.synchronizationId();
|
||||
const type = idFromSynchronized(this.constructor);
|
||||
for (let i = 0; i < packets.length; i++) {
|
||||
packets[i].data.synchronized = {id, type};
|
||||
}
|
||||
if (this.packetsAreIdempotent()) {
|
||||
this._idempotentPackets = packets;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user