in src/firefox/rdp-client.js [229:257]
_readMessage() {
const { data, rdpMessage, error, fatal } = parseRDPMessage(this._incoming);
this._incoming = data;
if (error) {
this.emit(
'error',
new Error(`Error parsing RDP packet: ${String(error)}`),
);
// Disconnect automatically on a fatal error.
if (fatal) {
this.disconnect();
}
// Caller can parse the next message if the error wasn't fatal
// (e.g. the RDP packet that couldn't be parsed has been already
// removed from the incoming data buffer).
return !fatal;
}
if (!rdpMessage) {
// Caller will need to wait more data to parse the next message.
return false;
}
this._handleMessage(rdpMessage);
// Caller can try to parse the next message from the remaining data.
return true;
}