<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[State Sync change in objects]]></title><description><![CDATA[<p>Hi! I'm still a bit new to colyseus, so I apologize if this question might sound dumb:</p>
<p>I'm trying to synchronize my server and client's state with an object</p>
<pre><code class="language-js">this.setState({
    key: {}
})
</code></pre>
<p>On the server, I have a piece of logic that handles messages from the client and modify the entire object, key.</p>
<p>When listening for changes on the client, nothing comes up:</p>
<pre><code class="language-js">this.room.listen('key', change =&gt; {
    console.log('key state has changed');
});
</code></pre>
<p>unless I do:</p>
<pre><code class="language-js">this.room.listen('key/:id', change =&gt; {
    console.log('key state has changed');
});
</code></pre>
<p>But, I don't want individual attributes of the object that changed. I want the entire object.</p>
<p>Unless the whole point of state sync is to synchronize small changes, then would I just broadcast the new Key Object as a work around?</p>
<p>Any help or suggestions would be greatly appreciated!</p>
]]></description><link>http://discuss.colyseus.io/topic/79/state-sync-change-in-objects</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Mar 2026 14:52:25 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/79.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 11 May 2018 08:09:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to State Sync change in objects on Fri, 11 May 2018 08:24:05 GMT]]></title><description><![CDATA[<p>Hi! I'm still a bit new to colyseus, so I apologize if this question might sound dumb:</p>
<p>I'm trying to synchronize my server and client's state with an object</p>
<pre><code class="language-js">this.setState({
    key: {}
})
</code></pre>
<p>On the server, I have a piece of logic that handles messages from the client and modify the entire object, key.</p>
<p>When listening for changes on the client, nothing comes up:</p>
<pre><code class="language-js">this.room.listen('key', change =&gt; {
    console.log('key state has changed');
});
</code></pre>
<p>unless I do:</p>
<pre><code class="language-js">this.room.listen('key/:id', change =&gt; {
    console.log('key state has changed');
});
</code></pre>
<p>But, I don't want individual attributes of the object that changed. I want the entire object.</p>
<p>Unless the whole point of state sync is to synchronize small changes, then would I just broadcast the new Key Object as a work around?</p>
<p>Any help or suggestions would be greatly appreciated!</p>
]]></description><link>http://discuss.colyseus.io/post/243</link><guid isPermaLink="true">http://discuss.colyseus.io/post/243</guid><dc:creator><![CDATA[zzmarkzz321]]></dc:creator><pubDate>Fri, 11 May 2018 08:24:05 GMT</pubDate></item><item><title><![CDATA[Reply to State Sync change in objects on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/75">@zzmarkzz321</a>, that's correct! The client will receive each single change you've made from the server-side.</p>
<p>You can catch all the properties by using:</p>
<pre><code>// client-side
this.room.listen('key/:attribute', change =&gt; {
    console.log(change.path.attribute, &quot;has changed to&quot;, change.value);
});
</code></pre>
<p>If you'd like to send the whole object directly, you can broadcast it from the server:</p>
<pre><code>// server-side
this.broadcast(yourNewObject);
</code></pre>
<p>And catch it using <code>onMessage</code> signal:</p>
<pre><code>this.room.onMessage.add(message =&gt; {
  console.log(&quot;here's the new object:&quot;, message);
});
</code></pre>
]]></description><link>http://discuss.colyseus.io/post/246</link><guid isPermaLink="true">http://discuss.colyseus.io/post/246</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to State Sync change in objects on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> Wow thanks so much for the quick and helpful response! Looking forward to diving deeper into the framework :)</p>
]]></description><link>http://discuss.colyseus.io/post/248</link><guid isPermaLink="true">http://discuss.colyseus.io/post/248</guid><dc:creator><![CDATA[zzmarkzz321]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>