<?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[Listen to non-primitive variables]]></title><description><![CDATA[<p>Hey!</p>
<p>I have a question regarding the .listen method for coloseus.js client.</p>
<p>So, the thing is, that I send the current position &amp; rotation to the server, which looks something like this:</p>
<pre><code>serverRoom.send({
    action: 'entity:transform:update',
    detail: {
        id: mesh.id,
        transformMatrix: [
            meshTransform.position.x,
            meshTransform.position.y,
            meshTransform.position.z,
            meshTransform.rotation.x,
            meshTransform.rotation.y,
            meshTransform.rotation.z,
            meshTransform.rotation.w,
        ],
    },
});
</code></pre>
<p>my room's state looks something like this:</p>
<pre><code>public onInit (options) {
    this.setState({
        entities: {}, // key_id: { id: 1, transformMatrix: [0,0,0,0,0,0,0] }
    });
}
</code></pre>
<p>Now, I want to listen for changes of other entities like that:</p>
<pre><code>serverRoom.listen('entities/:id/transformMatrix', (change: DataChange) =&gt; {
// listen for changes
});
</code></pre>
<p>But that doesn't seem to work (it only fires for the first add operation &amp; the remove operation; It doesn't ever fire the replace operation), if the transformMatrix variable is an array. My temporary workaround is, to set it to a string, and also send the transformMatrix as a string.</p>
<p>Is there a way I could get the array inside the <code>serverRoom.listen()</code> method?</p>
]]></description><link>http://discuss.colyseus.io/topic/50/listen-to-non-primitive-variables</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 13:56:59 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/50.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Mar 2018 14:01:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Listen to non-primitive variables on Invalid Date]]></title><description><![CDATA[<p>Hey!</p>
<p>I have a question regarding the .listen method for coloseus.js client.</p>
<p>So, the thing is, that I send the current position &amp; rotation to the server, which looks something like this:</p>
<pre><code>serverRoom.send({
    action: 'entity:transform:update',
    detail: {
        id: mesh.id,
        transformMatrix: [
            meshTransform.position.x,
            meshTransform.position.y,
            meshTransform.position.z,
            meshTransform.rotation.x,
            meshTransform.rotation.y,
            meshTransform.rotation.z,
            meshTransform.rotation.w,
        ],
    },
});
</code></pre>
<p>my room's state looks something like this:</p>
<pre><code>public onInit (options) {
    this.setState({
        entities: {}, // key_id: { id: 1, transformMatrix: [0,0,0,0,0,0,0] }
    });
}
</code></pre>
<p>Now, I want to listen for changes of other entities like that:</p>
<pre><code>serverRoom.listen('entities/:id/transformMatrix', (change: DataChange) =&gt; {
// listen for changes
});
</code></pre>
<p>But that doesn't seem to work (it only fires for the first add operation &amp; the remove operation; It doesn't ever fire the replace operation), if the transformMatrix variable is an array. My temporary workaround is, to set it to a string, and also send the transformMatrix as a string.</p>
<p>Is there a way I could get the array inside the <code>serverRoom.listen()</code> method?</p>
]]></description><link>http://discuss.colyseus.io/post/155</link><guid isPermaLink="true">http://discuss.colyseus.io/post/155</guid><dc:creator><![CDATA[bobalazek]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Listen to non-primitive variables on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/43">@bobalazek</a>,</p>
<p>This section needs more documentation and examples indeed.</p>
<p>You won't receive <code>&quot;replace&quot;</code> operations on <code>&quot;entities/:id/transformMatrix&quot;</code> this way because the <code>listen()</code> checks for the exact location of the variable, and it won't go deeper.</p>
<p>You can listen to arrays like this:</p>
<pre><code>serverRoom.listen(&quot;entities/:id/transformMatrix/:index&quot;, (change: DataChange) =&gt; {
  console.log(change.path.index + &quot; is now &quot; + change.value);
});
</code></pre>
<p>Hope this helps! Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/156</link><guid isPermaLink="true">http://discuss.colyseus.io/post/156</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Listen to non-primitive variables on Invalid Date]]></title><description><![CDATA[<p>Ok, thank you. Oh yeah, I did actually figure it this way, but in this case, I'm worried about performance, as it would need to do 7x (10x, if I would also include the scale) more callback calls as if it would just return the array. So the string solution does work ok (.split('|')/.join('|')), but it sends/receives more bits of data.<br />
Mean, for now, there is no way to hack around, so I would be able to get an array in &quot;one batch&quot;?</p>
]]></description><link>http://discuss.colyseus.io/post/157</link><guid isPermaLink="true">http://discuss.colyseus.io/post/157</guid><dc:creator><![CDATA[bobalazek]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>