diff --git a/packages/net/s13n/server.js b/packages/net/s13n/server.js index 50780e7..3ed301d 100644 --- a/packages/net/s13n/server.js +++ b/packages/net/s13n/server.js @@ -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]); } } } diff --git a/packages/net/s13n/synchronized.js b/packages/net/s13n/synchronized.js index fa7f823..35cf0eb 100644 --- a/packages/net/s13n/synchronized.js +++ b/packages/net/s13n/synchronized.js @@ -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; }