Files
node-screenlogic/messages/SLVersionMessage.js
Parnic ed99d411b2 Minor optimization to set buffer size appropriately
This avoids unnecessary allocations/reallocations while decoding a message by pre-sizing the buffer to the amount we know it will require. I feel like there's probably a better way to handle this, but this works for now.
2020-02-10 21:36:13 -06:00

33 lines
563 B
JavaScript
Executable File

'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 8120;
exports.SLVersionMessage = class SLVersionMessage extends SLMessage {
constructor(buf) {
var size;
if (buf) {
size = buf.readInt32LE(4) + 8;
}
super(0, MSG_ID, size);
if (buf) {
this._wroteSize = true;
this.writeBuffer(buf, 0);
this.decode();
}
}
decode() {
super.decode();
this.version = this.readSLString();
}
static getResponseId() {
return MSG_ID + 1;
}
};