Thursday 16 March 2017

Synchronizing Socket.IO calls across multiple clients

I'm pretty new to Javascript, Node, socket.io, and multiplayer game development in general, so I apologize in advance for anything obvious that I missed.

I have a node.js server that, when a browser goes to a particular website, creates a socket.io connection with that user. The server-side code receives any messages from a player and forwards it to whatever other players need that message

I'm trying to synchronize function calls across different browsers, so that they're called at as close to the same time as possible.

The expected workflow:

  1. Player 1 sends a message that commands players 2 and 3 to run a function at the same time (in this case, a Countdown) as soon as possible
  2. The server receives the message and sends it to Players 2 and 3
  3. Players 2 and 3 both receive the message and start the countdown at the same time (or as close to the same time as possible)

Is there a standard way to synchronize calls like this across different socket connections?



via Sprimate

No comments:

Post a Comment