hdckit
Version:
A pure Node.js client for the OpenHarmony Device Connector
25 lines (24 loc) • 690 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const MAX_CONNECTKEY_SIZE = 32;
class ChannelHandShake {
constructor() {
this.channelId = 0;
this.connectKey = '';
}
deserialize(buf) {
let offset = 0;
this.banner = buf.subarray(0, 12);
offset += 12;
this.channelId = buf.readUInt32BE(offset);
}
serialize() {
const buffers = [];
buffers.push(this.banner);
const connectKey = Buffer.alloc(MAX_CONNECTKEY_SIZE);
connectKey.write(this.connectKey);
buffers.push(connectKey);
return Buffer.concat(buffers);
}
}
exports.default = ChannelHandShake;