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