Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.id = "";
this._tick0 = 0;
this._tick1 = 0;
this._hasReceivedError = false;
this.blocks = [];
this.messageChunks = [];
this._expectedChannelId = 0;
options = options || {};
this.signatureLength = options.signatureLength || 0;
this.options = options;
this._packetAssembler = new PacketAssembler({
minimumSizeInBytes: 0,
readMessageFunc: readRawMessageHeader
});
this._packetAssembler.on("message", (messageChunk) => this._feed_messageChunk(messageChunk));
this._packetAssembler.on("newMessage", (info, data) => {
if (doPerfMonitoring) {
// record tick 0: when the first data is received
this._tick0 = get_clock_tick();
}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
const MessageBuilderBase = function (options) {
options = options || {};
this.signatureLength = options.signatureLength || 0;
this.options = options;
this.packetAssembler = new PacketAssembler({readMessageFunc: readRawMessageHeader});
const self = this;
this.packetAssembler.on("message", function (messageChunk) {
self._feed_messageChunk(messageChunk);
});
this.packetAssembler.on("newMessage", function (info, data) {
if(doPerfMonitoring) {
// record tick 0: when the first data is received
self._tick0 = get_clock_tick();
}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
TCP_transport.prototype._install_socket = function (socket) {
assert(socket);
const self = this;
self.name = " Transport " + counter;
counter += 1;
self._socket = socket;
// install packet assembler ...
self.packetAssembler = new PacketAssembler({
readMessageFunc: readRawMessageHeader,
minimumSizeInBytes: self.headerSize
});
self.packetAssembler.on("message", function (message_chunk) {
_on_message_received.call(self, message_chunk);
});
self._socket.on("data", function (data) {
self.bytesRead += data.length;
if (data.length > 0) {
self.packetAssembler.feed(data);
}
}).on("close", function (had_error) {
protected _install_socket(socket: Socket) {
assert(socket);
this._socket = socket;
if (doDebug) {
debugLog("_install_socket ", this.name);
}
// install packet assembler ...
this.packetAssembler = new PacketAssembler({
readMessageFunc: readRawMessageHeader,
minimumSizeInBytes: this.headerSize
});
/* istanbul ignore next */
if (!this.packetAssembler) {
throw new Error("Internal Error");
}
this.packetAssembler.on("message", (messageChunk: Buffer) => this._on_message_received(messageChunk));
this._socket
.on("data", (data: Buffer) => this._on_socket_data(data))
.on("close", (hadError) => this._on_socket_close(hadError))
.on("end", (err: Error) => this._on_socket_end(err))
.on("error", (err: Error) => this._on_socket_error(err));