From e80c40a7754e7fa7a6c702b8a2d5ac98f6485759 Mon Sep 17 00:00:00 2001 From: Malloc of Kuzkycyziklistan Date: Mon, 22 May 2017 22:50:36 -0500 Subject: [PATCH] smol changes e --- client/src/Crypto.ts | 3 +++ client/src/Packet.ts | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/Crypto.ts b/client/src/Crypto.ts index e69de29..6f132eb 100644 --- a/client/src/Crypto.ts +++ b/client/src/Crypto.ts @@ -0,0 +1,3 @@ +class KeyExchange { + +} \ No newline at end of file diff --git a/client/src/Packet.ts b/client/src/Packet.ts index 7ba5dc7..dfd23d9 100644 --- a/client/src/Packet.ts +++ b/client/src/Packet.ts @@ -30,18 +30,24 @@ class Packet { } public getBytes(): Uint8Array { - var messageSize = 1; + var headerSize = 1, bodySize = 0; this._regions.forEach(region => { - messageSize += region.byteLength + 1; + bodySize += region.byteLength; + + ++headerSize; if(region.byteLength >= 254 && region.byteLength <= 0xFFFF) - messageSize += 2; + headerSize += 2; else - messageSize += 4; + headerSize += 4; }); - var buffer = new Uint8Array(messageSize); + var buffer = new Uint8Array(headerSize + bodySize); + var headerPtr = 1, bodyPtr = 0; + buffer[0] = this._id % 256; this._regions.forEach(region => { }); + + return buffer; } } \ No newline at end of file