Hey.
BattleNode.prototype.commandPacket = function (command) { var data = new Buffer(command.length + 3); data.writeUInt8(0xFF, 0); data.writeUInt8(BE_COMMAND_PACKET, 1); data.writeUInt8(this.sequence, 2); data.write(command, 3); this.sequence = (this.sequence >= 255) ? 0 : this.sequence + 1; var packet = this.createBEPacket(data); return packet; } BattleNode.prototype.createBEPacket = function(payload) { var packet = new Buffer(payload.length + 6); // payload + header var header = new Buffer([0x42, 0x45, 0x00, 0x00, 0x00, 0x00]); var crc = crc32(payload); header.writeInt32BE(crc.readInt32LE(0), 2); header.copy(packet); payload.copy(packet, 6); return packet; } // The command variable comes already in Windows-1252 encoding. And you need to create a buffer with the same encoding.
I tried through iconv-lite. Nothing intelligible came out. Any ideas?