refactor: decouple pointer events

This commit is contained in:
cha0s 2019-04-12 12:19:06 -05:00
parent 255f92760d
commit b3dfd7cf2d

View File

@ -169,9 +169,8 @@ throughputTicker.on('tick', () => {
Decoder.throughput = 0; Decoder.throughput = 0;
Encoder.throughput = 0; Encoder.throughput = 0;
}); });
// Input messages. // Mouse/touch movement.
const messageHandle = setInterval(() => { const pointerMovementHandle = setInterval(() => {
// Mouse/touch movement.
do { do {
if (isPointingAtAnything()) { if (isPointingAtAnything()) {
const normal = createMoveToNormal(pointingAt); const normal = createMoveToNormal(pointingAt);
@ -182,6 +181,9 @@ const messageHandle = setInterval(() => {
} }
actionRegistry.state = actionRegistry.state.delete('MoveTo'); actionRegistry.state = actionRegistry.state.delete('MoveTo');
} while (false); } while (false);
}, 1000 / 15);
// Input messages.
const inputHandle = setInterval(() => {
if (actionState !== actionRegistry.state) { if (actionState !== actionRegistry.state) {
actionState = actionRegistry.state; actionState = actionRegistry.state;
socket.send(new InputPacket(JSON.stringify(actionRegistry.state.toJS()))); socket.send(new InputPacket(JSON.stringify(actionRegistry.state.toJS())));