summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheMas3212 <mas3212@gmail.com>2023-09-24 20:53:18 +1000
committerTheMas3212 <mas3212@gmail.com>2023-09-24 20:53:18 +1000
commit3f7c96f26d2613aa522ff3a0c7dcf877677c1e97 (patch)
tree538b0f43e13481101a6644e36e6279e3ebb67f38
parent24b8e412adc0bbecf1840280ed9b30bc131b7b8d (diff)
downloadtasd-js-3f7c96f26d2613aa522ff3a0c7dcf877677c1e97.tar.gz
tasd-js-3f7c96f26d2613aa522ff3a0c7dcf877677c1e97.zip
Cleanup InputChunk
-rw-r--r--src/packets/input.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/packets/input.ts b/src/packets/input.ts
index b084ebe..915c3b7 100644
--- a/src/packets/input.ts
+++ b/src/packets/input.ts
@@ -1,4 +1,5 @@
import { PACKET_TYPES } from "../constants";
+import { readUint32, readUint64, readUint8, writeUint32, writeUint64, writeUint8 } from "../utils";
import { TASDPacket, buildBuffer } from "./utils";
export class InputChunkPacket implements TASDPacket {
@@ -10,11 +11,11 @@ export class InputChunkPacket implements TASDPacket {
return this.inputs.length + 1;
}
static fromBuffer(buffer: Uint8Array) {
- return new InputChunkPacket(buffer[0], buffer.subarray(1));
+ return new this(readUint8(buffer, 0), buffer.subarray(1));
}
toBuffer(g_keylen: number): Uint8Array {
const payload = new Uint8Array(this.inputs.length + 1);
- payload[0] = this.port;
+ writeUint8(this.port, payload, 0);
payload.set(this.inputs, 1);
return buildBuffer(g_keylen, this.key, payload);
}