let packer add the headers

This commit is contained in:
Lewis Moten
2024-05-14 16:08:23 -04:00
parent f32380a301
commit da7feaf09e
6 changed files with 124 additions and 98 deletions

View File

@@ -6,7 +6,8 @@ import {
bitsToInt,
bytesToBits,
numberToBytes,
numberToHex
numberToHex,
numberToAscii
} from "./converters";
const dispatcher = new Dispatcher('StreamManager', ['change']);
@@ -74,13 +75,14 @@ export const applyPacket = ({
}
if(DATA.length < length) {
const copy = new Uint8ClampedArray(length);
copy.set(DATA.subarray(0, DATA.length));
copy.set(DATA.subarray(0, DATA.length), 0);
DATA = copy;
}
DATA.set(bytes, offset);
delete BITS[packetIndex];
dispatcher.emit('packetReceived');
} else {
console.log("Failed", sequence);
if(!FAILED_SEQUENCES.includes(sequence))
FAILED_SEQUENCES.push(sequence);
}