<?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[How to influence roomId for new room?]]></title><description><![CDATA[<p>Is there a way to choose or influence what the roomId will be when a new instance of a room is created?</p>
<p>For example, if I do something like</p>
<pre><code>gameServer.register(&quot;chat&quot;, ChatRoom).then((handler) =&gt; {
  handler.
    on(&quot;create&quot;, (room) =&gt; console.log(&quot;room created:&quot;, room.roomId)).
    on(&quot;dispose&quot;, (room) =&gt; console.log(&quot;room disposed:&quot;, room.roomId)).
    on(&quot;join&quot;, (room, client) =&gt; console.log(client.id, &quot;joined&quot;, room.roomId)).
    on(&quot;leave&quot;, (room, client) =&gt; console.log(client.id, &quot;left&quot;, room.roomId));
})
</code></pre>
<p>and set max clients to 2, when a new client joins the <code>&quot;chat&quot;</code> room then a new room instance gets created with a unique <code>roomId</code>. That's great, but the room IDs are not so friendly and so if I want one player to give his room ID to another so they can play in the same game, I would like friendlier room IDs. Can the server (or better yet the client) somehow influence the room ID either by choosing it directly or providing a suffix or prefix?</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/topic/234/how-to-influence-roomid-for-new-room</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 09:14:49 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/234.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Apr 2019 15:11:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to influence roomId for new room? on Invalid Date]]></title><description><![CDATA[<p>Is there a way to choose or influence what the roomId will be when a new instance of a room is created?</p>
<p>For example, if I do something like</p>
<pre><code>gameServer.register(&quot;chat&quot;, ChatRoom).then((handler) =&gt; {
  handler.
    on(&quot;create&quot;, (room) =&gt; console.log(&quot;room created:&quot;, room.roomId)).
    on(&quot;dispose&quot;, (room) =&gt; console.log(&quot;room disposed:&quot;, room.roomId)).
    on(&quot;join&quot;, (room, client) =&gt; console.log(client.id, &quot;joined&quot;, room.roomId)).
    on(&quot;leave&quot;, (room, client) =&gt; console.log(client.id, &quot;left&quot;, room.roomId));
})
</code></pre>
<p>and set max clients to 2, when a new client joins the <code>&quot;chat&quot;</code> room then a new room instance gets created with a unique <code>roomId</code>. That's great, but the room IDs are not so friendly and so if I want one player to give his room ID to another so they can play in the same game, I would like friendlier room IDs. Can the server (or better yet the client) somehow influence the room ID either by choosing it directly or providing a suffix or prefix?</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/802</link><guid isPermaLink="true">http://discuss.colyseus.io/post/802</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to influence roomId for new room? on Invalid Date]]></title><description><![CDATA[<p>hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/387">@cmdt-ed</a>, you can override the <code>roomId</code> during <code>onInit()</code>:</p>
<pre><code>// server-side
onInit(options) {
  this.roomId = options.roomId;
}
</code></pre>
<pre><code>// client-side
var room = client.join(&quot;chat&quot;, { roomId: &quot;hello&quot; })
</code></pre>
<p>Keep in mind that making sure these values are unique is in your hands this way.</p>
]]></description><link>http://discuss.colyseus.io/post/803</link><guid isPermaLink="true">http://discuss.colyseus.io/post/803</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to influence roomId for new room? on Invalid Date]]></title><description><![CDATA[<p>Thanks. That sounds great. Since javascript is single-threaded, I should just be able to check the proposed roomId on the server, right?</p>
<p>Could you point me to the property or method to get the room IDs on the server?</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/804</link><guid isPermaLink="true">http://discuss.colyseus.io/post/804</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to influence roomId for new room? on Invalid Date]]></title><description><![CDATA[<p>Looking at the code it seems like maybe I should look at <code>this.presence.smembers(roomName)</code> to get a list of all rooms (not just the available ones). Does that sound like the right thing to check to make sure I am not creating a roomId which already exists?</p>
]]></description><link>http://discuss.colyseus.io/post/808</link><guid isPermaLink="true">http://discuss.colyseus.io/post/808</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to influence roomId for new room? on Fri, 12 Apr 2019 02:25:32 GMT]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/387">@cmdt-ed</a>, it's not ideal but you can use that. The <code>Presence</code> API doesn't currently support <code>sismember</code> - which is better for checking that, I'd appreciate if you can send me a pull-request adding it! <a href="https://redis.io/commands/sismember" rel="nofollow">https://redis.io/commands/sismember</a></p>
<p>There's only two <code>Presence</code> implementations now, both can implement this method:</p>
<ul>
<li><code>LocalPresence</code>: for single-threaded environments <a href="https://github.com/colyseus/colyseus/blob/master/src/presence/LocalPresence.ts" rel="nofollow">link</a></li>
<li><code>RedisPresence</code>: for multi-threaded environments <a href="https://github.com/colyseus/colyseus/blob/master/src/presence/RedisPresence.ts" rel="nofollow">link</a></li>
</ul>
<p>Cheers</p>
]]></description><link>http://discuss.colyseus.io/post/809</link><guid isPermaLink="true">http://discuss.colyseus.io/post/809</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Fri, 12 Apr 2019 02:25:32 GMT</pubDate></item><item><title><![CDATA[Reply to How to influence roomId for new room? on Invalid Date]]></title><description><![CDATA[<p>OK, I'll look into doing that. I don't have much experience with redis, promises, async and even javascript but I'll see what I can do.</p>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/814</link><guid isPermaLink="true">http://discuss.colyseus.io/post/814</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>