This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent 046b3d0023
commit b460fa1aa0
7 changed files with 70 additions and 16 deletions
+16 -1
View File
@@ -12,11 +12,20 @@ export class Encoder extends Transform {
}
_transform(obj: Response, encoding, callback) {
console.log("Idz: Response:", obj);
console.log("Idz: Res: Object:", obj);
let buf: Buffer;
switch (obj.type) {
case "account_lock_res":
buf = Buffer.alloc(0x0020);
buf.writeUInt16LE(MSG.ACCOUNT_LOCK_RES, 0x0000);
buf.writeInt8(obj.field_0018, 0x0018);
buf.writeInt16LE(obj.field_001A, 0x001a);
buf.writeUInt32LE(obj.field_001C.getTime() / 1000, 0x001c);
break;
case "get_config_data_res":
buf = Buffer.alloc(0x01a0);
buf.writeUInt16LE(MSG.GET_CONFIG_DATA_RES, 0x0000);
@@ -63,6 +72,12 @@ export class Encoder extends Transform {
return callback(new Error(`No writer fn for ${obj["type"]}`));
}
console.log("Idz: Res: Encoded:", buf.toString("hex"));
if (buf.readInt16LE(0) === 0) {
throw new Error("MESSAGE TYPE CODE YOU FUCKING IDIOT");
}
return callback(null, buf);
}
}