The mouse position synchronization is getting heavier and heavier.

Asked 2 years ago, Updated 2 years ago, 83 views

I use websocket to send the location at the time of mouse move, and when the location is sent, I write the process of reflecting it in the coordinates of the image.

It's not heavy at first, but it gets heavier after using it for a while. (I mean, it jumps off)

Is there anything like that that could be the cause?Please let me know.

Environment, etc.

  • websocket 0.2.1
  • Node.js 0.10.25
  • Node server running

Send mouse position (I try to call every mouse move event for body tag)

var data={
  type: 'mouth_point',
  mousePoint: {x:e.clientX, y:e.clientY}
};
ws.send (JSON.stringify(data));

Only reflected when mouse location information is sent

cursorTag.style.left=data.mouthPoint.x+"px";
cursorTag.style.top=data.mouthPoint.y+"px";

Current State Report -- 11/17 Add
 Thank you for your reply.When refactoring code after this issue occurs
 Before I knew it, the phenomenon stopped happening...The code in the mouse position transmission and reception section is
 There seems to have been no problem, so another problem may have affected it.
 I am very sorry that the result was like this despite your advice.

websocket

2022-09-30 18:06

1 Answers

Is there a possibility that you have added a mouse move event handler every time an event occurs and sent a lot of requests?

If you output the location information of the mouse every time you receive it, you will be able to check if you send it multiple times in one event.
If you are using Chrome, you can output to the console using console.log ("string").


2022-09-30 18:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.