Closed perspectivezoom closed 1 year ago
Hi @perspectivezoom, the room.state
on the client-side is not immediately populated after connecting, but after a few milliseconds, it does get synchronized.
Both your .listen("activePlayer")
and .room.onStateChange(()=>{})
should be triggering after joining the room. If they're not triggering you may be hitting a known server config issue that causes the state not to sync, documented here. If your project was created via npm create colyseus-app@latest
that config is already set.
"Websocket event. Is there a way I can decode the payload to see if the server is sending the right thing or not?"
You can use the playground tool to inspect every message https://docs.colyseus.io/tools/playground/
Let me know if that helps, otherwise please share your project so I can take a look. Cheers!
If they're not triggering you may be hitting a known server config issue that causes the state not to sync, https://github.com/colyseus/colyseus/issues/510#issuecomment-1507828422.
This was totally it. Setting "useDefineForClassFields": false
, everything magically works.
the
room.state
on the client-side is not immediately populated after connecting, but after a few milliseconds, it does get synchronized
According to console.log
, I don't ever see the blank state. As far as my application code is concerned, it works immediately.
You can use the playground tool to inspect every message https://docs.colyseus.io/tools/playground/
It doesn't seem to work for me. I can see the room, but no active connections. But as no longer have an immediate use for inspecting websocket events and this is a problem only tangentially related, I'm closing this issue out. Thanks so much @endel for your help. I've spent pretty much the entire day trying to figure this out.
Is this intended? Or am I missing some trigger or doing something out of order to cause
room.state
to not be populated?I've been trying to reproduce https://github.com/ourcade/tic-tac-toe-multiplayer-starter, and I've also looked at https://github.com/endel/colyseus-tic-tac-toe, and both of them seem to assume that
room.state
is populated from initial join.If it is intended to be initially empty, how do I trigger the initial population of the
room.state
?console.log
state
seems to be populated correctly atonJoin
time on the serverclient.joinOrCreate
shows empty values forroom.state