<?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 handshake problem between server and unity client]]></title><description><![CDATA[<p>Hi developers,</p>
<p>Did you guys try to use colyseus continuously develop some game? Just like you publish game A and later game B, but use the same server to hold these two games. I meat a problem.</p>
<p>I develop game A and publish, example, a write codes about AGameRoom extends Room and AGameState extends Schema, and then I publish game A.</p>
<p>Then I write codes about BGameRoom extends Room and BGameState extends Schema, i add the code to the same server and restart. The different game player will enter different game room and use different game logic.</p>
<p>Then the game A unity client will crash at the Schema's implicit method 'handshake', because the server side has AGameState and BGameState, but game A client only has AGameState.</p>
<p>How can I solve this?</p>
<p>I read the schema source code, and I found context may help. Did anyone has the same problem like me? Thanks.</p>
]]></description><link>http://discuss.colyseus.io/topic/390/schema-handshake-problem-between-server-and-unity-client</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 20:25:25 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/390.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 03 Jul 2020 03:51:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schema handshake problem between server and unity client on Invalid Date]]></title><description><![CDATA[<p>Hi developers,</p>
<p>Did you guys try to use colyseus continuously develop some game? Just like you publish game A and later game B, but use the same server to hold these two games. I meat a problem.</p>
<p>I develop game A and publish, example, a write codes about AGameRoom extends Room and AGameState extends Schema, and then I publish game A.</p>
<p>Then I write codes about BGameRoom extends Room and BGameState extends Schema, i add the code to the same server and restart. The different game player will enter different game room and use different game logic.</p>
<p>Then the game A unity client will crash at the Schema's implicit method 'handshake', because the server side has AGameState and BGameState, but game A client only has AGameState.</p>
<p>How can I solve this?</p>
<p>I read the schema source code, and I found context may help. Did anyone has the same problem like me? Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/1276</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1276</guid><dc:creator><![CDATA[jiabuda]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema handshake problem between server and unity client on Fri, 03 Jul 2020 14:44:19 GMT]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/697">@jiabuda</a>, I'm glad you're enjoying it and using it for your second game!</p>
<p>You're right about the Context. By default the <code>@type()</code> annotation is going to use a &quot;global context&quot;. By having all structures inside the global context, they're all going to be synched during handshake.</p>
<p>I'm restructuring most of <code>@colyseus/schema</code> lately, and I'm going to add a utility to help with this, as follows:</p>
<pre><code>import { type, Context, DefinitionType } from &quot;@colyseus/schema&quot;;

function createContext() {
    const context = new Context();
    return function (definition: DefinitionType) {
        return type(definition, context);
    }
}
</code></pre>
<p>You can use this function to generate a special <code>@type()</code> that is going to bind to a specific context, so you can use a different one for each of your games. Example:</p>
<pre><code>// &quot;game1.ts&quot;
export const type = createContext();

// other file
import { type } from &quot;./game1&quot;;

class State extends Schema {
  @type(&quot;string&quot;) // ... your definitions as usual
}
</code></pre>
<p>This utility is going to be available as <code>Context.create()</code> on a next version!</p>
<p>Hope this helps. Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/1277</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1277</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Fri, 03 Jul 2020 14:44:19 GMT</pubDate></item><item><title><![CDATA[Reply to Schema handshake problem between server and unity client on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a></p>
<p>Thanks endel, I use the same way as you provide above. And the u3d colleague already annotate the code inside handshake to prevent schema check. Cause we check the same code in colyseus.js, we found js type client did not check the schema.</p>
<p>I think the schema should bind with specific room but not a context? How do you think about it.</p>
]]></description><link>http://discuss.colyseus.io/post/1278</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1278</guid><dc:creator><![CDATA[jiabuda]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Schema handshake problem between server and unity client on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a></p>
<p>And another problem, when A game and B game share the same schema, that would be a problem.</p>
<p>gameA use PlayeInfo Schema in ARoomSchema and gameB use PlayerInfo too in BRoomSchema. That would be a situation, the PlayerInfo could only implement one specific context but not two.</p>
]]></description><link>http://discuss.colyseus.io/post/1279</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1279</guid><dc:creator><![CDATA[jiabuda]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>