I am having a look at redeveloping an old flash based top-down zombie shooter game I made in highschool so that it supports multiplayer using
socket.io. My experience over the last 5 years has been mostly writing server-side code, so writing the game logic itself on the server isn't a huge concern. The places I am having trouble with due to my very limited experience with sockets specifically is:
- What the most appropriate input and output should be to and from the server in a game context.
- How much data is appropriate to send.
Off the top of my head, I imagine the process would look something like:
- The server runs the game (using NodeJS).
- Clients that connect send their input to the server (key presses, clicks, etc).
- Those inputs are queued against the client ID on the server and interpreted to move their character or whatever it does.
- The server sends back the updated position of the client as well as everything else around the client in the "world".
The last point is where I have the most doubts. Assuming a reasonable collection of objects in the world, I am not confident that sending through the position of everything every ~30ms to every client would be sustainable (though I really don't know what is sustainable with web sockets). Then again, maybe it actually is perfectly fine to do this.
Obviously I can limit the amount of objects by only sending ones who have actually been updated (so static objects would never come through, etc) but I am not sure whether that is necessary at all or whether that is something extremely crucial. I also don't see this working if we implemented something like everyone being able to fire 100s of projectiles (or some other massive collection of constantly updating objects).
Are there any general guidelines or common knowledge around how much data you would expect to see come through a web socket and how frequently? Am I way off the mark or would this work okay for a moderate amount of clients?
I realize this all sounds very broad so to try tighten it up a bit I am specifically interested in how much data is realistic to send through web sockets and how frequently. Any auxiliary information based on the above is a great addition.