mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Rename CursorSyncer to ViewportSyncer
This commit is contained in:
parent
10283712ef
commit
8f3b7b9bd9
2 changed files with 2 additions and 60 deletions
|
@ -7,7 +7,7 @@ window.panzoom = require("pan-zoom");
|
||||||
|
|
||||||
// Our files
|
// Our files
|
||||||
import RippleLink from './RippleLink';
|
import RippleLink from './RippleLink';
|
||||||
import CursorSyncer from './CursorSyncer';
|
import ViewportSyncer from './ViewportSyncer';
|
||||||
import { get } from './Utilities';
|
import { get } from './Utilities';
|
||||||
|
|
||||||
class BoardWindow extends EventEmitter
|
class BoardWindow extends EventEmitter
|
||||||
|
@ -76,7 +76,7 @@ class BoardWindow extends EventEmitter
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
// Track the mouse position
|
// Track the mouse position
|
||||||
this.cursorSyncer = new CursorSyncer(this.rippleLink, this.cursorUpdateFrequency)
|
this.viewportSyncer = new ViewportSyncer(this.rippleLink, this.cursorUpdateFrequency)
|
||||||
|
|
||||||
// RippleLink message bindings
|
// RippleLink message bindings
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
class CursorSyncer
|
|
||||||
{
|
|
||||||
constructor(inRippleLink, syncFrequency)
|
|
||||||
{
|
|
||||||
// The ripple link we should send the cursor updates down
|
|
||||||
this.rippleLink = inRippleLink;
|
|
||||||
// The target frequency in fps at we should send sursor updates.
|
|
||||||
this.cursorUpdateFrequency = syncFrequency;
|
|
||||||
|
|
||||||
this.otherClients = [];
|
|
||||||
|
|
||||||
// Register ourselves to start sending cursor updates once the ripple
|
|
||||||
// link connects
|
|
||||||
this.rippleLink.on("connect", this.setup.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
setup()
|
|
||||||
{
|
|
||||||
// The last time we sent a cursor update to the server.
|
|
||||||
this.lastCursorUpdate = 0;
|
|
||||||
|
|
||||||
document.addEventListener("mousemove", (function(event) {
|
|
||||||
this.cursorPosition = {
|
|
||||||
X: event.clientX,
|
|
||||||
Y: event.clientY
|
|
||||||
};
|
|
||||||
|
|
||||||
setTimeout((function() {
|
|
||||||
// Throttle the cursor updates we send to the server - a high
|
|
||||||
// update frequency here will just consume bandwidth and is only
|
|
||||||
// noticable if you have a good connection
|
|
||||||
if(+new Date() - this.lastCursorUpdate < 1 / this.cursorUpdateFrequency)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Update the server on the mouse's position
|
|
||||||
this.sendCursorUpdate();
|
|
||||||
|
|
||||||
this.lastFrameStart = +new Date();
|
|
||||||
}).bind(this), 1 / this.cursorUpdateFrequency);
|
|
||||||
|
|
||||||
}).bind(this));
|
|
||||||
|
|
||||||
this.sendCursorUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
sendCursorUpdate()
|
|
||||||
{
|
|
||||||
// Update the server on the mouse's position
|
|
||||||
this.rippleLink.send({
|
|
||||||
"event": "CursorPosition",
|
|
||||||
"AbsCursorPosition": this.cursorPosition
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CursorSyncer;
|
|
Loading…
Reference in a new issue