0

I have a multiplayer online game I am making, it uses node.js, and the communication between the server and the client is as follows:

In the beginning, all of the needed models are sent from the server to the client when the client asks for it. From then on, the server sends all connected clients get sent all position data 60 times a second. As of now, the only things that the client sends the server are keyboard inputs, other than that there is a chat that is working fine when both the client and server are fine, but that is besides the issue.

The server manages all of the physics, and the client manages all of the rendering.

The problem is, besides the fact that it doesnt even work in the first place if the server sending speed is 60 a second but only on the inisialisation of the client, as in when the client is done joining it can be turned from like 1 or 5 or 10 back up to 60, is that when it does work, and the browser tab is taken out of focus, all calculations and recieving from the server stops. I don't know why that is, but it causes an issue when the page gets focus again, as in when the page gets focus again the game goes through rendering all that has happened at a fast speed while the client was away. This causes issues as it can take a while before it is ready to use again, and any inputs have a magnified effect and get put at the end of the rewind thing.

I have tried making it stop rendering while the screen was turned away, but that didn't work. I don't know how to fix the issue, besides maybe making the server check each and every player to see if it is active or not before sending the files individually, which doesn't seem to be a good solution. I would prefer to still be able to use the "io.emit" method.

  • Could you [put event listeners on the leaving from and returning to the tab events](https://stackoverflow.com/questions/10338704/javascript-to-detect-if-user-changes-tab) to disable and reenable any sockets/polling, respectively? – Alexander Nied Sep 24 '21 at 20:15
  • i dont know how to stop the sockets from recieving, and if i were to do that, then it might end up resetting the socket ids, and that would not be ideal – Kitty Craft0 Sep 27 '21 at 12:55

0 Answers0