smol changes

e
This commit is contained in:
Malloc of Kuzkycyziklistan 2017-05-22 22:50:36 -05:00
parent 6ca8bade21
commit e80c40a775
2 changed files with 14 additions and 5 deletions

View file

@ -0,0 +1,3 @@
class KeyExchange {
}

View file

@ -30,18 +30,24 @@ class Packet {
} }
public getBytes(): Uint8Array { public getBytes(): Uint8Array {
var messageSize = 1; var headerSize = 1, bodySize = 0;
this._regions.forEach(region => { this._regions.forEach(region => {
messageSize += region.byteLength + 1; bodySize += region.byteLength;
++headerSize;
if(region.byteLength >= 254 && region.byteLength <= 0xFFFF) if(region.byteLength >= 254 && region.byteLength <= 0xFFFF)
messageSize += 2; headerSize += 2;
else 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 => { this._regions.forEach(region => {
}); });
return buffer;
} }
} }