<?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[Schema Child Objects Not Updated]]></title><description><![CDATA[<p>Hello,</p>
<p>Enjoying using the library for a work project so far.</p>
<p>I am sending a message from the server to client:<br />
this.broadcast(message, { afterNextPatch: true });</p>
<p>Before this line I update the servers state as follows:<br />
this.state.dealer.card1 = &quot;9h&quot;</p>
<p>On the C# side after I receive the message I'd expect the rooms state to be updated but it seems to only update top level properties such as this.state.example.  Is there any way to let the server know all the states properties are &quot;dirty&quot; and should be updated?  The only workaround I've found now is to send a large copy of the state in the message itself.  I thought the afterNextPatch option would ensure my state was fully updated before the message would be received?</p>
<p>I'm using the Unity C# client.</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/topic/317/schema-child-objects-not-updated</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 08:48:28 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/317.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Jan 2020 07:01:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Invalid Date]]></title><description><![CDATA[<p>Hello,</p>
<p>Enjoying using the library for a work project so far.</p>
<p>I am sending a message from the server to client:<br />
this.broadcast(message, { afterNextPatch: true });</p>
<p>Before this line I update the servers state as follows:<br />
this.state.dealer.card1 = &quot;9h&quot;</p>
<p>On the C# side after I receive the message I'd expect the rooms state to be updated but it seems to only update top level properties such as this.state.example.  Is there any way to let the server know all the states properties are &quot;dirty&quot; and should be updated?  The only workaround I've found now is to send a large copy of the state in the message itself.  I thought the afterNextPatch option would ensure my state was fully updated before the message would be received?</p>
<p>I'm using the Unity C# client.</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/1051</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1051</guid><dc:creator><![CDATA[jconradi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/598">@jconradi</a>, this is supposed to be working properly, I've just checked myself using the unity demo project.</p>
<p>When using <code>afterNextPatch</code> the message is going to be sent right after the patch, so you can use the data in the state when evaluating that message in the client-side.</p>
<p>From the server-side, all <code>Schema</code> structures sit behind a proxy, so whenever you update any value, they're flagged as &quot;dirty&quot; for the next patch.</p>
<p>If you can provide an example project so I can reproduce would be nice. Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/1052</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1052</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Thu, 30 Jan 2020 16:28:38 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> Thanks for getting back to me :)</p>
<p>I'm using a Node server and C# Unity client.</p>
<p>Server Example:</p>
<p>class ShortDeckState extends Schema {<br />
@type(&quot;string&quot;) gameState: ShortDeckGameState;<br />
@type(&quot;int32&quot;) gameStateCountdown: number;<br />
@type({ map: ShortDeckPlayer }) players = new MapSchema&lt;ShortDeckPlayer&gt;();<br />
@type(ShortDeckTable) table: ShortDeckTable = new ShortDeckTable();<br />
}</p>
<p>class ShortDeckTable extends Schema {<br />
@type(&quot;string&quot;) flopCard1: string;<br />
@type(&quot;string&quot;) flopCard2: string;<br />
@type(&quot;string&quot;) flopCard3: string;</p>
<pre><code>@type(&quot;string&quot;) turnCard: string;
@type(&quot;string&quot;) riverCard: string;

@type(&quot;string&quot;) dealerCard1: string;
@type(&quot;string&quot;) dealerCard2: string;
</code></pre>
<p>}</p>
<p>// Later in my code I receive a player message, and update the cards on the table:<br />
this.state.table.flopCard1 = flopCards[0];<br />
this.state.table.flopCard2 = flopCards[1];<br />
this.state.table.flopCard3 = flopCards[2];</p>
<p>this.state.gameState = ShortDeckGameState.TurnWager;</p>
<p>// Immediately after I send an event to the clients that gamestate has changed.<br />
// Before I wasn't including the table and players items in the message but I found I needed<br />
// it to get my data accross.<br />
var message = new ShortDeckWagerStateChanged();<br />
message.wagerState = this.state.gameState;<br />
message.wagerStateCountdown = this.WagerTimeoutSeconds;<br />
message.table = this.state.table;<br />
message.players = this.state.players;</p>
<pre><code>    this.broadcast(message, { afterNextPatch: true });
</code></pre>
<p>Client:<br />
// On the client side after I receive ShortDeckWagerStateChanged I try to access room.state.table to get the flop cards but they are always null.  gameState has the correct value however</p>
<p>private void OnShortDeckMessage(object message)<br />
{<br />
if (message is ShortDeckWagerStateChanged)<br />
{<br />
var wagerChangedMessage = message as ShortDeckWagerStateChanged;</p>
<pre><code>      // This is always null
       var flopCard1 = this.room.State.table.flopCard1;
    }
}
</code></pre>
<p>I hope that illustrates the point a little bit.  I copied it from my codebase with some properties removed on the main state class for brevity.  Thanks for any pointers you can give me here.  I'd like to be able to just use the messages to notify clients of something interesting happening (folded, bet, etc...) and then the clients query the state object for data.  This way the clients joining the server in the middle or the clients in the middle of the game are querying the same state data and not having to use a bunch of messages with different properties.</p>
]]></description><link>http://discuss.colyseus.io/post/1054</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1054</guid><dc:creator><![CDATA[jconradi]]></dc:creator><pubDate>Thu, 30 Jan 2020 16:28:38 GMT</pubDate></item><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> Another bit of information...my broadcast:<br />
this.broadcast(message, { afterNextPatch: true });</p>
<p>happens in a callback to a clock setInterval.  It does appear that when I update my child object (table in this case) in the servers onMessage then everything is fine and the state is updated on the client.</p>
<p>However, I really need this functionality and am wondering if there is a workaround.  I found this by trying to add a broadcastPatch() call inside the clocks callback but I would get a stack overflow.  I'm not sure if this is a bug or something I&quot;m doing wrong.  Here's an example:</p>
<p>In response to a player message this function is called:</p>
<p>startAnteBetCountdown() {<br />
if (this.betTimeout &amp;&amp; this.betTimeout.active) {<br />
return;<br />
}</p>
<pre><code>this.betTimeout = this.clock.setTimeout(() =&gt; {
  this.betTimeout = null;

  this.game.dealAnteCards();

  this.broadcastStateChangeMessage();
  // This next function starts another timer...
  this.startFlopBetCountdown();
}, (this.WagerTimeoutSeconds + 1) * 1000);
</code></pre>
<p>}</p>
<p>broadcastStateChangeMessage() {<br />
var message = new ShortDeckWagerStateChanged();<br />
message.wagerState = this.state.gameState;<br />
message.wagerStateCountdown = this.WagerTimeoutSeconds;<br />
message.table = this.state.table;<br />
message.players = this.state.players;</p>
<pre><code>this.broadcast(message, { afterNextPatch: true });
</code></pre>
<p>}</p>
]]></description><link>http://discuss.colyseus.io/post/1055</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1055</guid><dc:creator><![CDATA[jconradi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Invalid Date]]></title><description><![CDATA[<p>Hopped on a chat in discord with <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a>.  Definitely a stand up guy!  I really appreciate his help and this library is working exactly as advertised.</p>
<p>He discovered that my real problem was due to referencing some of properties in the rooms' state in messages that I was sending to clients.  For example, earlier you can see how I am sending ShortDeckWagerStateChanged.  That message has properties that references properties in my state which is wrong.  From what I understand this will run the schema encoding logic and leave my state altered.</p>
<p>If I really wanted to do that then Schema has a clone() method on it but I didn't investigate doing that.</p>
]]></description><link>http://discuss.colyseus.io/post/1056</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1056</guid><dc:creator><![CDATA[jconradi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema Child Objects Not Updated on Invalid Date]]></title><description><![CDATA[<p>Hey! I'm having a difficulty to implement Child Schema Type on client-side (unity) , it always gives me error like 'schema mismatch ... ' could you show me an example, please. For example, if the folowing is the server-side schema :<br />
class IAmAChild extends Schema {<br />
@type(&quot;number&quot;) x: number;<br />
@type(&quot;number&quot;) y: number;<br />
}<br />
class ChildSchemaTypes extends Schema {<br />
@type(IAmAChild) child: IAmAChild;<br />
@type(IAmAChild) secondChild: IAmAChild;<br />
}</p>
<p>How the client-side schema must be implemented?<br />
Thanks</p>
]]></description><link>http://discuss.colyseus.io/post/1470</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1470</guid><dc:creator><![CDATA[niaina]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>