This commit is contained in:
aozhiwei 2023-09-24 11:37:52 +08:00
parent afe2c8d890
commit 2eccca1186

View File

@ -94,11 +94,12 @@ class ClientNet {
async onParsePacket() {
let offset = 0;
while (this.recvBuf.length > offset + 12) {
while (this.recvBuf.length >= offset + 12) {
const msgSize = this.recvBuf.readUInt16LE(offset + 0);
const msgId = this.recvBuf.readUInt16LE(offset + 2);
const seqId = this.recvBuf.readUInt32LE(offset + 4);
const magicCode = this.recvBuf.readUInt16LE(offset + 8);
//console.log('onParsePacket', msgSize, msgId, seqId, magicCode);
if (this.recvBuf.length >= offset + 12 + msgSize) {
await this.processMsg(msgId,
this.recvBuf.slice