I'm trying to do little multiplayer game with Flask-SocketIO on server side and javascript client. I have player coordinates (x, y) in player class instance on server, but I can't emit that data periodically without earlier emit from client to server to get this data. If client listening for player coordinates which are calculated on server I want to send that coordinates every small part of time automatically, but I don't know how to do that. Additionally, It looks like that as long as any player is in the playing field, players who have closed the game are still displaying, the function to remove them from the player list is unable to perform. How to deal with this?
Asked
Active
Viewed 336 times
0
-
Please add some code samples which you have tried. – Akash Basudevan Apr 30 '20 at 21:13
-
Code is not important in this case. When I tried it on javascript server I sent it through setInterval, but there is no such function in python. As for the problem with disconnecting players, it looks like javascript is asynchronous by default and python is not, so it probably the problem. – Szafran Apr 30 '20 at 21:29
-
Have you looked in the "ayncio" module for python? It helps making python functions async. Also you can use ".sleep" function on the socket emit event in a while true loop for setting a time interval. – Akash Basudevan Apr 30 '20 at 21:32