A
A
artem_music2016-08-01 10:14:02
Node.js
artem_music, 2016-08-01 10:14:02

How to implement multiplayer on socket.io?

Good afternoon, I have a question, how is threading organized in multiplayer games?

For example, there are two object tanks controlled by two players. What is the best and most convenient way to implement multiplayer? When to send activity data? At the moment I see two options for logic:

  • Attach handlers to keyboard buttons - send a request to the server for each click, which in turn will notify the second player about the actions of the first.
  • Checking the position of all players with a certain time interval - that is, the action is initialized by the server, not by the player's actions.


In the first case, traffic is saved: no actions on the part of the players - no traffic. How to do it right? Please push in the right direction.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lxfr, 2016-08-01
@artem_music

For any actions, pour data about the state of objects into the database (whichever you know best), when data enters the database, notify all connected clients about these states, and render positions based on this data. Before saving to the database, check for cheats (can there be such a state?).
Send data only for actions, respectively.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question