1
0
Fork 0

[client] Send a viewport update before requesting new chunks

This commit is contained in:
Starbeamrainbowlabs 2017-07-29 21:26:06 +01:00
parent d6b4b50588
commit b34fb59575
2 changed files with 21 additions and 12 deletions

View File

@ -320,6 +320,23 @@ class BoardWindow extends EventEmitter
window.addEventListener("resize", this.matchWindowSize.bind(this));
}
/**
* Sends the current viewport to the server.
*/
sendViewport() {
this.rippleLink.send({
Event: "ViewportUpdate",
NewViewport: {
X: parseInt(this.viewport.x),
Y: parseInt(this.viewport.y),
Width: parseInt(this.viewport.width),
Height: parseInt(this.viewport.height)
}
});
this.lastViewportUpdate = +new Date();
}
/**
* Handles events generated by pan-zoom, the package that handles the
* dragging and zooming of the whiteboard.
@ -345,17 +362,7 @@ class BoardWindow extends EventEmitter
if(+new Date() - this.lastViewportUpdate < (1 / this.cursorSyncer.cursorUpdateFrequency) * 1000)
return false;
this.rippleLink.send({
Event: "ViewportUpdate",
NewViewport: {
X: parseInt(this.viewport.x),
Y: parseInt(this.viewport.y),
Width: parseInt(this.viewport.width),
Height: parseInt(this.viewport.height)
}
});
this.lastViewportUpdate = +new Date();
this.sendViewport();
}).bind(this));
}

View File

@ -61,7 +61,9 @@ class ChunkCache
}
if(missingChunks.length > 0) {
// Asynchronously request them from the server
// Make sure that the server knows our current viewport
this.boardWindow.sendViewport();
// Asynchronously request the missing chunks from the server
this.boardWindow.rippleLink.send({
"Event": "ChunkUpdateRequest",
"ForgottenChunks": missingChunks