Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. cmdt.ed
  3. Best
  • Profile
  • More
    • Continue chat with cmdt.ed
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Best posts made by cmdt.ed

RE: Listeners triggered even though listening to different state properties

Sorry to reply to an old post but this was the one that finally helped me understand how to use listen so I thought it might be helpful to clarify for other users who are as dense as I am.

The documentation for listen at https://docs.colyseus.io/client-state-synchronization/ is painfully terse and confusing especially in how it uses the colon (:). From my understanding, if you have something like the following as your state:

{foo: bar: {baz: 'somevalue'} }

then you can listen for baz via

room.listen('foo/bar/baz', ...)

or via something like

room.listen('foo/:wildcard_1/:wildcard-2', ...)

That is you can either use the exact path or use wildcards but the text after the colon has no special meaning. I kept thinking that the :id and :attribute wildcards in the docs had a special meaning.

Hope that helps others who got confused like me.

Thanks again.

posted in Questions & Help • 17 Mar 2019, 20:22
RE: setState, @nosync, and other properties

Excellent! Thanks for the quick response.

I was confused on this so I'll summarize in case others come to this post in the future.

The @nosync decorator is needed because you might create an object foo that will be inside the state object and foo has properties bar and baz with bar being visible and baz being private. You would then use @nosync on baz since it is something inside the state that you want private. But for just other properties of the room but outside the state, those will not be synced.

posted in Questions & Help • 17 Mar 2019, 17:30

© 2023 Endel Dreyer