<?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[Join rooms sharing auth]]></title><description><![CDATA[<p>Hi everyone,<br />
Is there any example on how to use multiple rooms? And also how to share the authentication between different rooms?<br />
In my current flow I'm logging the user using a first game-room, sending credentials and using the onAuth method in the Room server.<br />
But then I would like to use different rooms for different maps, so which will be the best way to accomplish this?<br />
I know I can use <code>room = client.join('game_room', userData);</code> on the client side but what should I do to leave the room and move the user from one room to the other?<br />
Also,  will be possible to validate if the user was already authenticated before leave the first room? I really don't want to run all the validation process through the DB again.<br />
Maybe I could leave one room available as &quot;logged-users&quot; and allow users to join other rooms by checking if they are &quot;active&quot; in that specific room, I did some tests on that but didn't find a way to access other rooms on server side.</p>
<p>Thanks again!</p>
]]></description><link>http://discuss.colyseus.io/topic/154/join-rooms-sharing-auth</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Mar 2026 12:23:02 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/154.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Sep 2018 16:40:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Hi everyone,<br />
Is there any example on how to use multiple rooms? And also how to share the authentication between different rooms?<br />
In my current flow I'm logging the user using a first game-room, sending credentials and using the onAuth method in the Room server.<br />
But then I would like to use different rooms for different maps, so which will be the best way to accomplish this?<br />
I know I can use <code>room = client.join('game_room', userData);</code> on the client side but what should I do to leave the room and move the user from one room to the other?<br />
Also,  will be possible to validate if the user was already authenticated before leave the first room? I really don't want to run all the validation process through the DB again.<br />
Maybe I could leave one room available as &quot;logged-users&quot; and allow users to join other rooms by checking if they are &quot;active&quot; in that specific room, I did some tests on that but didn't find a way to access other rooms on server side.</p>
<p>Thanks again!</p>
]]></description><link>http://discuss.colyseus.io/post/509</link><guid isPermaLink="true">http://discuss.colyseus.io/post/509</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Sat, 29 Sep 2018 18:27:11 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/167">@dpastorini</a> said in <a href="/post/509">Join rooms sharing auth</a>:</p>
<blockquote>
<p>don't want to run all the validation process through the DB again.</p>
</blockquote>
<p>Well, I use a traditional way for that. I produce a token for each client when they first login to the server. Then, they use the token and their ID whenever they join to a new room. Following that, the server checks if ID&amp;token pair exists in the DB.</p>
<p>I think the method above is quite cheap. Another easy thing would be to have a global object in the server that is independent of any room, which keeps the credentials of the users. You can use such global objects to check if a user is already authenticated.</p>
]]></description><link>http://discuss.colyseus.io/post/510</link><guid isPermaLink="true">http://discuss.colyseus.io/post/510</guid><dc:creator><![CDATA[halilbilgin]]></dc:creator><pubDate>Sat, 29 Sep 2018 18:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/144">@halilbilgin</a> , thanks for your reply!</p>
<blockquote>
<p>Well, I use a traditional way for that. I produce a token for each client when they first login to the server. Then, they use the token and their ID whenever they join to a new room. Following that, the server checks if ID&amp;token pair exists in the DB.</p>
</blockquote>
<p>That will be the same as use the user/password from the user object on the server side (which I don't share on the client) and hit again the DB. Even when that's is just a cheap query it will be still a query and a Promise to wait for information.</p>
<blockquote>
<p>Another easy thing would be to have a global object in the server that is independent of any room, which keeps stores the credentials of the users. You can use such global objects to check if a user is already authenticated.</p>
</blockquote>
<p>This is more like what I'm looking for, that's why I was thinking to use something like a &quot;logged-users&quot; room, as something global. That's why I was asking if Colyseus has something like this already implemented or if I will need to extend the Colyseus server class to make a custom implementation on my own (if this is the case it will be something that I would share later), but the way I see it, it could be something as part of Colyseus &quot;core&quot;.</p>
<p>Also I didn't find any good join/leave rooms flow sample, so maybe I'm missing something?</p>
<p>Thanks!</p>
]]></description><link>http://discuss.colyseus.io/post/511</link><guid isPermaLink="true">http://discuss.colyseus.io/post/511</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Yes, I got what you mean and I am also interested in some built-in way for this kind of needs.</p>
<p>For join/leave room procedure, I do it by sending message from client to server or vice versa first, then close the connection in both sides, which is not nice :/.</p>
]]></description><link>http://discuss.colyseus.io/post/512</link><guid isPermaLink="true">http://discuss.colyseus.io/post/512</guid><dc:creator><![CDATA[halilbilgin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<blockquote>
<p>For join/leave room procedure, I do it by sending message from client to server or vice versa first, then close the connection in both sides, which is not nice :/.</p>
</blockquote>
<p>Yeah, exactly, I saw the client.leave and room.join on the client side, and the Room.close on server side, but I wasn't able to get for example a rooms list on server side from inside a room. Do you know if there's a way to do that? Or do you have any ideas on how to do it?</p>
<p>Best,</p>
]]></description><link>http://discuss.colyseus.io/post/513</link><guid isPermaLink="true">http://discuss.colyseus.io/post/513</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Ok, I think I was able figure it part of how to do this by reading other posts...<br />
For reference: <a href="https://discuss.colyseus.io/topic/149/using-multiple-rooms-to-support-one-large-map/10" rel="nofollow">https://discuss.colyseus.io/topic/149/using-multiple-rooms-to-support-one-large-map/10</a><br />
There says to use room.presence functions for multiple rooms, so now I'm able to check if the user really left the first room before allow it to join the second with something like <code>if(this.presence.keys[roomId+':'+client.id])</code>, will this be ok?<br />
There's none documentation about any of this, all I saw about presence there was related to the server and Redis, which I don't think it's the same, right?<br />
Best,</p>
]]></description><link>http://discuss.colyseus.io/post/515</link><guid isPermaLink="true">http://discuss.colyseus.io/post/515</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/167">@dpastorini</a>, sorry the delay to answer. I've just published some docs for <code>Presence</code> here: <a href="http://colyseus.io/docs/api-presence/" rel="nofollow">http://colyseus.io/docs/api-presence/</a></p>
<p>Just be careful when using <code>Presence</code> methods manually to avoid memory leaks. It's common to set values there and forget to clean them up.</p>
]]></description><link>http://discuss.colyseus.io/post/518</link><guid isPermaLink="true">http://discuss.colyseus.io/post/518</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>That's great!!! Thank you <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> ! :D<br />
I'm still struggling on how to change rooms and keep using the same logged user data, and in between I broke my Phaser implementation, so I'll probably rollback my last changes and start again just by using the presence methods.<br />
I'll keep you posted on how it goes and let you know as soon I get a working sample.<br />
Thanks again!</p>
]]></description><link>http://discuss.colyseus.io/post/519</link><guid isPermaLink="true">http://discuss.colyseus.io/post/519</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> , one more question: let's say I'm on the Room1, and then I join Room2, is possible in the server side to access the data that's already in the Room1?<br />
Because in the examples you have something like <code>room.state.players[client.sessionId]</code>, so I would like to know if it's possible to access the data in first room from the second, maybe using <code>super.allRooms[roomId]</code> or something like that?</p>
<p>Thanks!</p>
]]></description><link>http://discuss.colyseus.io/post/520</link><guid isPermaLink="true">http://discuss.colyseus.io/post/520</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Invalid Date]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/167">@dpastorini</a>, that's not possible. You <strong>can</strong> do it by storing the data you'd like to retrieve in the <code>presence</code> (e.g. <code>this.presence.hset(&quot;roomxyz&quot;, &quot;key&quot;, &quot;value&quot;)</code>), and then retrieving it in the other room (<code>this.presence.hget(&quot;roomxyz&quot;, &quot;key&quot;)</code>).</p>
<p>I wouldn't recommend doing this, though. It's likely that you'll face some issue when the data is not available anymore, in case the room gets disposed, for example.</p>
]]></description><link>http://discuss.colyseus.io/post/521</link><guid isPermaLink="true">http://discuss.colyseus.io/post/521</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Join rooms sharing auth on Fri, 05 Oct 2018 02:37:40 GMT]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> thanks for you quick reply, as you said... yeah.. too many issues already LOL<br />
I'll go for the database option to persist the data between room changes, I'm working on it now, the idea is to save the player progress &gt; leave the room &gt; join the new room &gt; re-authenticate the user with the data in the session and reload the progress.<br />
I though it will be too expensive in terms of server response time, but keep a room or persist too much information in the presence could end up been even more expensive than just hit the DB to get the data.<br />
Best,</p>
]]></description><link>http://discuss.colyseus.io/post/522</link><guid isPermaLink="true">http://discuss.colyseus.io/post/522</guid><dc:creator><![CDATA[dpastorini]]></dc:creator><pubDate>Fri, 05 Oct 2018 02:37:40 GMT</pubDate></item></channel></rss>