mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Fix linepart pushes
This commit is contained in:
parent
6e58139eea
commit
9cd578512b
1 changed files with 8 additions and 1 deletions
|
@ -65,7 +65,8 @@ class Pencil
|
|||
this.unsentSegments.push(nextPoint);
|
||||
this.currentLineSegments.push(nextPoint);
|
||||
|
||||
if(new Date() - this.lastServerPush > this.pushDelay)
|
||||
var timeSinceLastPush = new Date() - this.lastServerPush;
|
||||
if(timeSinceLastPush > this.pushDelay)
|
||||
this.sendUnsent();
|
||||
}
|
||||
|
||||
|
@ -89,6 +90,10 @@ class Pencil
|
|||
* unsent segments buffer.
|
||||
*/
|
||||
sendUnsent() {
|
||||
// Don't bother if there aren't any segments to push
|
||||
if(this.unsentSegments.length == 0)
|
||||
return;
|
||||
|
||||
// It's time for another push of the line to the server
|
||||
this.rippleLink.send({
|
||||
Event: "LinePart",
|
||||
|
@ -97,6 +102,8 @@ class Pencil
|
|||
});
|
||||
// Reset the unsent segments buffer
|
||||
this.unsentSegments = [];
|
||||
// Update the time we last pushed to the server
|
||||
this.lastServerPush = +new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue