OnMessage vs OnChange Based Performance

Hello guys,

I am new to using Colyseus, and I am making a turn based game.

I have a question about good practices for good performance.

When produces a turn change, or to communicate that there is a winner...

how should it be done? Is it better to deal with broadcast messages to all users or put a room.state.onChange callback on the client side and hear changes in different status properties?


Hi @TheRedHead, welcome!

That's really up to you. Here's the major difference from using a message or the state:

  • The data in the state will remain there when new players join, or a player disconnects & reconnects back to the game.
  • The state is broadcasted automatically at every "patch interval" (default is 50ms - see docs)
  • Messages are sent immediately, and only once. There's no built-in way to re-send a particular message when a player disconnects & reconnects for example.

Hope this helps,

thanks for your answer!!