diff --git a/packages/entity/packets/entity-list-update-entity.packet.js b/packages/entity/packets/entity-list-update-entity.packet.js index 67903cf..a0189d6 100644 --- a/packages/entity/packets/entity-list-update-entity.packet.js +++ b/packages/entity/packets/entity-list-update-entity.packet.js @@ -28,7 +28,7 @@ export default class EntityListUpdateEntityPacket extends Packet { const unpacked = super.unpack(packet); const {data} = unpacked; for (let i = 0; i < data.length; i++) { - data[i].packets = BundlePacket.unpack(data[i].packets); + data[i].packets = BundlePacket.unpack(data[i].packets).data; } return unpacked; } diff --git a/packages/entity/packets/entity-update-trait.packet.js b/packages/entity/packets/entity-update-trait.packet.js index d8ac9b9..f5f1181 100644 --- a/packages/entity/packets/entity-update-trait.packet.js +++ b/packages/entity/packets/entity-update-trait.packet.js @@ -34,7 +34,7 @@ export default class EntityUpdateTraitPacket extends SynchronizedUpdatePacket { for (let i = 0; i < data.traits.length; i++) { const {default: Trait} = fromId(data.traits[i].type); data.traits[i].type = Trait.type(); - data.traits[i].packets = BundlePacket.unpack(data.traits[i].packets); + data.traits[i].packets = BundlePacket.unpack(data.traits[i].packets).data; } return unpacked; } diff --git a/packages/net/packet/bundle.packet.js b/packages/net/packet/bundle.packet.js index a1a4fd4..2d57cf3 100644 --- a/packages/net/packet/bundle.packet.js +++ b/packages/net/packet/bundle.packet.js @@ -64,9 +64,10 @@ export default class BundlePacket extends Packet { const {default: Packet} = fromId(packetId); // Unpack and instantiate the packet. const unpacked = Packet.unpack(packedPacket); - packets.push(new Packet(unpacked)); + packets.push(new Packet(unpacked.data)); } - return packets; + unpacked.data = packets; + return unpacked; } } \ No newline at end of file diff --git a/packages/net/packet/packet.js b/packages/net/packet/packet.js index 9319a1e..905e54e 100644 --- a/packages/net/packet/packet.js +++ b/packages/net/packet/packet.js @@ -1,4 +1,5 @@ import schemapack from 'schemapack'; +import {BINARY_EVENT} from './socket.io-parser'; export class Packet { @@ -22,9 +23,9 @@ export class Packet { static pack(packet) { return this.builder.encode({ - id: packet.id, - nsp: packet.nsp, - type: packet.type, + id: packet.id || 0, + nsp: packet.nsp || '/', + type: packet.type || BINARY_EVENT, _id: packet.data[0], data: packet.data[1], }); diff --git a/packages/topdown/packets/layers-update-layer.packet.js b/packages/topdown/packets/layers-update-layer.packet.js index 24fc58e..6914834 100644 --- a/packages/topdown/packets/layers-update-layer.packet.js +++ b/packages/topdown/packets/layers-update-layer.packet.js @@ -28,9 +28,7 @@ export default class LayersUpdateLayerPacket extends Packet { const unpacked = super.unpack(packet); const {data} = unpacked; for (let i = 0; i < data.length; i++) { - data[i].layerPackets = BundlePacket.unpack( - data[i].layerPackets - ); + data[i].layerPackets = BundlePacket.unpack(data[i].layerPackets).data; } return unpacked; } diff --git a/packages/topdown/packets/room-update-layers.packet.js b/packages/topdown/packets/room-update-layers.packet.js index 33f7268..1035549 100644 --- a/packages/topdown/packets/room-update-layers.packet.js +++ b/packages/topdown/packets/room-update-layers.packet.js @@ -20,7 +20,7 @@ export default class RoomUpdateLayersPacket extends SynchronizedUpdatePacket { static unpack(packet) { const unpacked = super.unpack(packet); const {data} = unpacked; - data.layersPackets = BundlePacket.unpack(data.layersPackets); + data.layersPackets = BundlePacket.unpack(data.layersPackets).data; return unpacked; }