more debugging

This commit is contained in:
Soph :3 2024-05-03 20:32:10 +03:00
parent c72b2c494e
commit 59d2db1785
Signed by: sophie
GPG key ID: EDA5D222A0C270F2

View file

@ -54,11 +54,13 @@ export class Server {
const packetId = socket.data.dataBuffer.readUint8(0); const packetId = socket.data.dataBuffer.readUint8(0);
const packetLength = this.lengthMap.get(packetId); const packetLength = this.lengthMap.get(packetId);
if(!packetLength) { if(!packetLength) {
log.debug("Incorrect packet ID", packetId, "packet length could not be found.")
return; return;
}; };
if(socket.data.dataBuffer.byteLength < packetLength) return; if(socket.data.dataBuffer.byteLength < packetLength) return;
this.handlePacket(socket.data.dataBuffer.copyWithin(0, 1), packetId, socket); this.handlePacket(socket.data.dataBuffer.subarray(1), packetId, socket);
log.debug("Parsed packet", packetId, "with packet length", packetLength)
socket.data.dataBuffer = socket.data.dataBuffer.subarray(packetLength+1); socket.data.dataBuffer = socket.data.dataBuffer.subarray(packetLength+1);
parseBuffer(); parseBuffer();
} }