avocado-old/packages/net/packet/variant.js

24 lines
470 B
JavaScript
Raw Normal View History

2020-05-21 08:57:23 -05:00
import msgpack from 'msgpack-lite';
export default function (Superclass) {
return class VariantPacket extends Superclass {
static pack(packet) {
packet.data[1] = msgpack.encode(packet.data[1]);
return super.pack(packet);
}
static get schema() {
return {
...super.schema,
data: 'buffer',
};
}
static unpack(packet) {
const data = super.unpack(packet);
return msgpack.decode(data);
}
}
}