This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent b460fa1aa0
commit de8b654f9c
8 changed files with 82 additions and 34 deletions
+13 -3
View File
@@ -1,8 +1,11 @@
import iconv = require("iconv-lite");
import { Transform } from "stream";
import { MSG } from "./defs";
import { Response } from "./response";
const sjis = "shift_jis";
export class Encoder extends Transform {
constructor() {
super({
@@ -26,14 +29,21 @@ export class Encoder extends Transform {
break;
case "get_config_data_res":
case "create_team_res":
buf = Buffer.alloc(0x0ca0);
buf.writeUInt16LE(MSG.CREATE_TEAM_RES, 0x0000);
iconv.encode(obj.name, sjis).copy(buf, 0x0024);
break;
case "get_config_res":
buf = Buffer.alloc(0x01a0);
buf.writeUInt16LE(MSG.GET_CONFIG_DATA_RES, 0x0000);
buf.writeUInt16LE(MSG.GET_CONFIG_RES, 0x0000);
buf.writeUInt16LE(obj.status, 0x0002);
break;
case "get_config_data_2_res":
case "get_config_2_res":
buf = Buffer.alloc(0x230);
buf.writeUInt16LE(MSG.GET_CONFIG_DATA_2_RES, 0x0000);
buf.writeUInt16LE(obj.status, 0x0002);