Code cleanup, optimize clearing udpBuffer

This commit is contained in:
matt 2022-07-01 17:51:17 +00:00
parent c648af5358
commit ce8f08318d
2 changed files with 9 additions and 26 deletions

View File

@ -329,10 +329,8 @@ export default class Display {
x, y, w, h,
vx, vy, w, h);
if (this.isNewFrame(x, y, h, w)) {
this._flipCnt += 1;
}
}
this._damageBounds.left = this._damageBounds.top = 65535;
this._damageBounds.right = this._damageBounds.bottom = 0;

View File

@ -986,10 +986,6 @@ export default class RFB extends EventTargetMixin {
if (udpBuffer.has(id)) {
let item = udpBuffer.get(id);
if (!item) {
Log.Info("Item Missing id: " + id);
return;
}
item.recieved_pieces += 1;
item.data[i] = u8.slice(16);
item.total_bytes += item.data[i].length;
@ -1018,18 +1014,6 @@ export default class RFB extends EventTargetMixin {
udpBuffer.set(id, item);
}
}
// TODO: this loop is inefficent and likely unneccesary.
// perhaps just keep n number of incomplete messages
const now = Date.now();
for (const [key, value] of udpBuffer.entries()) {
// Drop any messages older than 100ms
if (now - value.arrival > 100) {
Log.Info('Removed id: ' + key + ' Buffer size: ' + udpBuffer.size);
udpBuffer.delete(key);
}
}
}
}
@ -2869,6 +2853,7 @@ export default class RFB extends EventTargetMixin {
case encodings.pseudoEncodingLastRect:
if (document.visibilityState !== "hidden") {
this._display.flip();
this._udpBuffer.clear();
}
break;
case encodings.encodingTight: