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.