Saturday, July 2, 2022
HomeGame DevelopmentSignalling time-expiry to shoppers in a browser-based multiplayer recreation

Signalling time-expiry to shoppers in a browser-based multiplayer recreation


I am attempting to develop my first ever browser-based multiplayer recreation that makes use of my very own websocket server which has no multi-threading functionality.

It is going to be a recreation the place gamers attempt to be the quickest in fixing as many puzzles as doable in a specific period of time. Whoever solves a puzzle first wins that spherical and the subsequent puzzle is served, till time has expired. The participant who solved essentially the most puzzles first wins the sport.

To maintain the CPU-load of the server as little as doable, I am attempting to give you a technique that alerts shoppers when time has expired. You see, whereas video games are ongoing I am merely ready for enter from shoppers with socket choose and an inexpensive choose timeout. This works properly to maintain the CPU load down. However, as my server has no multi-threading functionality, I am attempting to forestall my server from monitoring ongoing video games in a busy whereas loop (regularly interrupting socket choose), merely to observe if time has expired.

So, I thought of merely ready for shopper enter and solely then sign the shopper that point has expired. And if per probability no participant is responding anymore (all of them disconnected, left recreation, and many others.), I merely mark the sport as completed if the sport state is requested at some later time.

Do you see any issues with this technique? And, are you able to counsel different methods that I could have ignored, that do not depend on a busy whereas loop?


Simply after posting the query I noticed that I have not thought issues via sufficient, as a result of I am confronted with the identical conundrum of signalling the beginning of the sport as nicely, after all, which truly is way more time vital. 🙁


Truly, after given it a bit extra thought nonetheless, I feel I can sign the beginning of the sport to all shoppers as quickly because the final participant has entered the sport. So that will not truly be all that problematic in any case.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments