UNPKG

shardy

Version:

Framework for online games and applications on Node.js

29 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Payload = exports.PayloadType = void 0; var PayloadType; (function (PayloadType) { PayloadType[PayloadType["Request"] = 0] = "Request"; PayloadType[PayloadType["Command"] = 1] = "Command"; PayloadType[PayloadType["Response"] = 2] = "Response"; })(PayloadType || (exports.PayloadType = PayloadType = {})); class Payload { static encode(serializer, type, name, id, data, error) { data = data ? data : Buffer.alloc(0); error = error ? error : ''; return serializer.encode({ type, name, id, data, error }); } static decode(serializer, data) { return serializer.decode(data); } static create(type, name, id, data, error) { data = data ? data : Buffer.alloc(0); error = error ? error : ''; return { type, name, id, data, error }; } static check(payload) { return Object.values(PayloadType).includes(payload.type); } } exports.Payload = Payload; //# sourceMappingURL=Payload.js.map