parser: fix header parsing.
This commit is contained in:
parent
2881294bf4
commit
3f5c5cf603
@ -127,7 +127,6 @@ Parser.prototype.parse = function parse(data) {
|
||||
|
||||
if (!this.header) {
|
||||
this.header = this.parseHeader(data);
|
||||
this.waiting = this.header.size;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -145,15 +144,16 @@ Parser.prototype.parse = function parse(data) {
|
||||
try {
|
||||
payload = this.parsePayload(this.header.cmd, data);
|
||||
} catch (e) {
|
||||
this.emit('error', e);
|
||||
this.waiting = 24;
|
||||
this.header = null;
|
||||
this.emit('error', e);
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit('packet', payload);
|
||||
this.waiting = 24;
|
||||
this.header = null;
|
||||
|
||||
this.emit('packet', payload);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -185,6 +185,8 @@ Parser.prototype.parseHeader = function parseHeader(data) {
|
||||
return this.error('Packet length too large: %dmb.', utils.mb(size));
|
||||
}
|
||||
|
||||
this.waiting = size;
|
||||
|
||||
checksum = data.readUInt32LE(20, true);
|
||||
|
||||
return new Header(cmd, size, checksum);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user