diffusion
Version:
Diffusion JavaScript client
96 lines (95 loc) • 4.17 kB
JavaScript
;
/**
* @module Services
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseCommandHeaderSerialiser = exports.CommandHeaderSerialiser = exports.ResponseCommandHeaderSerialiserClass = exports.CommandHeaderSerialiserClass = void 0;
var conversation_id_serialiser_1 = require("./../conversation/conversation-id-serialiser");
var Codec = require("./../io/codec");
var serialiser_1 = require("./../serialisers/serialiser");
var command_header_1 = require("./command-header");
/**
* Serialiser for {@link CommandHeader}
*/
var CommandHeaderSerialiserClass = /** @class */ (function (_super) {
__extends(CommandHeaderSerialiserClass, _super);
function CommandHeaderSerialiserClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Read a {@link CommandHeader} from the stream
*
* @param bis the input stream
* @return the {@link CommandHeader} that was read
*/
CommandHeaderSerialiserClass.prototype.read = function (bis) {
var service = Codec.readInt32(bis);
var cid = conversation_id_serialiser_1.CIDSerialiser.read(bis);
return new command_header_1.CommandHeader(service, cid);
};
/**
* Write a {@link CommandHeader} to the stream
*
* @param bos the output stream
* @param value the {@link CommandHeader} to be written
*/
CommandHeaderSerialiserClass.prototype.write = function (bos, value) {
Codec.writeInt32(bos, value.service);
conversation_id_serialiser_1.CIDSerialiser.write(bos, value.cid);
};
return CommandHeaderSerialiserClass;
}(serialiser_1.AbstractSerialiser));
exports.CommandHeaderSerialiserClass = CommandHeaderSerialiserClass;
/**
* Serialiser for a response {@link CommandHeader}
*/
var ResponseCommandHeaderSerialiserClass = /** @class */ (function (_super) {
__extends(ResponseCommandHeaderSerialiserClass, _super);
function ResponseCommandHeaderSerialiserClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Write a response {@link CommandHeader} to the stream
*
* @param bos the output stream
* @param value the {@link CommandHeader} to be written
*/
ResponseCommandHeaderSerialiserClass.prototype.write = function (bos, value) {
conversation_id_serialiser_1.CIDSerialiser.write(bos, value.cid);
};
/**
* Read a response {@link CommandHeader} from the stream
*
* @param bis the input stream
* @return the {@link CommandHeader} that was read
*/
ResponseCommandHeaderSerialiserClass.prototype.read = function (bis) {
var cid = conversation_id_serialiser_1.CIDSerialiser.read(bis);
return new command_header_1.CommandHeader(0, cid);
};
return ResponseCommandHeaderSerialiserClass;
}(serialiser_1.AbstractSerialiser));
exports.ResponseCommandHeaderSerialiserClass = ResponseCommandHeaderSerialiserClass;
/**
* The {@link CommandHeaderSerialiser} singleton
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.CommandHeaderSerialiser = new CommandHeaderSerialiserClass();
/**
* The {@link ResponseCommandHeaderSerialiser} singleton
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.ResponseCommandHeaderSerialiser = new ResponseCommandHeaderSerialiserClass();