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));
|
payload.push(synchronized.destroyPacket(informed));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const id = synchronized.synchronizationId();
|
|
||||||
const type = idFromSynchronized(synchronized.constructor);
|
|
||||||
const packets = synchronized.packetsFor(informed);
|
const packets = synchronized.packetsFor(informed);
|
||||||
for (let j = 0; j < packets.length; j++) {
|
for (let j = 0; j < packets.length; j++) {
|
||||||
const packet = packets[j];
|
payload.push(packets[j]);
|
||||||
packet.data.synchronized = {
|
|
||||||
id,
|
|
||||||
type,
|
|
||||||
};
|
|
||||||
payload.push(packet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,12 @@ export function SynchronizedMixin(Superclass) {
|
||||||
if (!Array.isArray(packets)) {
|
if (!Array.isArray(packets)) {
|
||||||
packets = [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()) {
|
if (this.packetsAreIdempotent()) {
|
||||||
this._idempotentPackets = packets;
|
this._idempotentPackets = packets;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user