<?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[Getting error when leaving room on OnDestroy (Unity)]]></title><description><![CDATA[<p>When the game object gets destroyed that holds the game room, I call room.Leave()</p>
<pre><code>    public void OnDestroy()
    {
        if (isRoomJoined)
        {
            this.Leave();
        }
    }
</code></pre>
<p>This throws an error whenever I do this though.</p>
<p>WebsocketSharp Error! An exception has occured while OnClose.</p>
<p>Is the issue that I'm leaving while the gameObject is being destroyed?</p>
<p>Edit:</p>
<p>Also, it appears that this doesn't have any actual affect on any other rooms and everything appears to be functioning normally. But it scares me for it to have this error popping up.</p>
<p>Update:</p>
<p>When I try to just leave the room without destroying the game object, I still see the issue</p>
<p>So it looks like the error is coming from this cast of WebSocket to Room.<br />
But I'm still not quite sure how to fix the issue.</p>
<p><img src="/assets/uploads/files/1529542863604-screen-shot-2018-06-20-at-5.59.57-pm-resized.png" alt="0_1529542860133_Screen Shot 2018-06-20 at 5.59.57 PM.png" class="img-responsive img-markdown" /></p>
<p>If I change this line in Room.cs it makes it work:<br />
<img src="/assets/uploads/files/1529543213559-screen-shot-2018-06-20-at-6.06.39-pm-resized.png" alt="0_1529543210037_Screen Shot 2018-06-20 at 6.06.39 PM.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://discuss.colyseus.io/topic/104/getting-error-when-leaving-room-on-ondestroy-unity</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 15:27:14 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/104.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Jun 2018 07:17:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Getting error when leaving room on OnDestroy (Unity) on Thu, 21 Jun 2018 01:06:57 GMT]]></title><description><![CDATA[<p>When the game object gets destroyed that holds the game room, I call room.Leave()</p>
<pre><code>    public void OnDestroy()
    {
        if (isRoomJoined)
        {
            this.Leave();
        }
    }
</code></pre>
<p>This throws an error whenever I do this though.</p>
<p>WebsocketSharp Error! An exception has occured while OnClose.</p>
<p>Is the issue that I'm leaving while the gameObject is being destroyed?</p>
<p>Edit:</p>
<p>Also, it appears that this doesn't have any actual affect on any other rooms and everything appears to be functioning normally. But it scares me for it to have this error popping up.</p>
<p>Update:</p>
<p>When I try to just leave the room without destroying the game object, I still see the issue</p>
<p>So it looks like the error is coming from this cast of WebSocket to Room.<br />
But I'm still not quite sure how to fix the issue.</p>
<p><img src="/assets/uploads/files/1529542863604-screen-shot-2018-06-20-at-5.59.57-pm-resized.png" alt="0_1529542860133_Screen Shot 2018-06-20 at 5.59.57 PM.png" class="img-responsive img-markdown" /></p>
<p>If I change this line in Room.cs it makes it work:<br />
<img src="/assets/uploads/files/1529543213559-screen-shot-2018-06-20-at-6.06.39-pm-resized.png" alt="0_1529543210037_Screen Shot 2018-06-20 at 6.06.39 PM.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://discuss.colyseus.io/post/341</link><guid isPermaLink="true">http://discuss.colyseus.io/post/341</guid><dc:creator><![CDATA[Imallic]]></dc:creator><pubDate>Thu, 21 Jun 2018 01:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to Getting error when leaving room on OnDestroy (Unity) on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> , does this change seem appropriate? If so, I could make a pull request for this change.</p>
]]></description><link>http://discuss.colyseus.io/post/344</link><guid isPermaLink="true">http://discuss.colyseus.io/post/344</guid><dc:creator><![CDATA[Imallic]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Getting error when leaving room on OnDestroy (Unity) on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/88">@imallic</a>, absolutely. I'll gladly merge this change. Thanks for sharing.</p>
]]></description><link>http://discuss.colyseus.io/post/345</link><guid isPermaLink="true">http://discuss.colyseus.io/post/345</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Getting error when leaving room on OnDestroy (Unity) on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a>, I have created the pull request: <a href="https://github.com/gamestdio/colyseus-unity3d/pull/40" rel="nofollow">https://github.com/gamestdio/colyseus-unity3d/pull/40</a></p>
]]></description><link>http://discuss.colyseus.io/post/347</link><guid isPermaLink="true">http://discuss.colyseus.io/post/347</guid><dc:creator><![CDATA[Imallic]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>