<?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[Joining specific rooms, playing against friends]]></title><description><![CDATA[<p>Hello!</p>
<p>How would you go about letting people join specific rooms? For example, suppose I want to play against my friends; how would I join their room? I saw Federkun's workaround <a href="https://github.com/gamestdio/colyseus/issues/10" rel="nofollow">here</a>, but it would be nice if this feature was included in Colyseus.</p>
<p>If this hasn't been implemented, is there any way I can help? :)</p>
]]></description><link>http://discuss.colyseus.io/topic/30/joining-specific-rooms-playing-against-friends</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 17:13:31 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/30.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Feb 2018 04:17:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Mon, 05 Feb 2018 04:18:22 GMT]]></title><description><![CDATA[<p>Hello!</p>
<p>How would you go about letting people join specific rooms? For example, suppose I want to play against my friends; how would I join their room? I saw Federkun's workaround <a href="https://github.com/gamestdio/colyseus/issues/10" rel="nofollow">here</a>, but it would be nice if this feature was included in Colyseus.</p>
<p>If this hasn't been implemented, is there any way I can help? :)</p>
]]></description><link>http://discuss.colyseus.io/post/82</link><guid isPermaLink="true">http://discuss.colyseus.io/post/82</guid><dc:creator><![CDATA[ScottyFillups]]></dc:creator><pubDate>Mon, 05 Feb 2018 04:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Mon, 05 Feb 2018 16:45:00 GMT]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/26">@ScottyFillups</a>,</p>
<p>Whilst it's on the framework's roadmap to have public room listing, it's currently possible to share the room id with friends, which allow them to connect directly to it.  (Docs: <a href="http://colyseus.io/docs/client-room/#properties" rel="nofollow">http://colyseus.io/docs/client-room/#properties</a>)</p>
<p>You'd need to handle this case on your own, though.</p>
<p>You have a couple of options, such as:</p>
<ol>
<li>Letting the user set a password for the private room upon creation, and prevent clients from joining without the password on <code>requestJoin</code>.</li>
</ol>
<pre><code>class MyRoom extends Room {
  onInit (options) {
    this.password = options.password;
  }

  requestJoin (options) {
    return (this.password &amp;&amp; options.password == this.password);
  }

}
</code></pre>
<ol start="2">
<li>Registering a new handler <code>&quot;private&quot;</code> for private rooms. Fresh clients could join only the <code>&quot;public&quot;</code> by default, while the <code>&quot;private&quot;</code> rooms could have the id shared with friends. On this setup there's a possibility that users can &quot;hack&quot; the JavaScript file, allowing to join the <code>&quot;private&quot;</code> rooms by default instead, but that's unlikely to happen.</li>
</ol>
<pre><code>gameServer.register(&quot;public&quot;, MyRoom);
gameServer.register(&quot;private&quot;, MyRoom);
</code></pre>
<p>Hope this helps! Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/85</link><guid isPermaLink="true">http://discuss.colyseus.io/post/85</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Mon, 05 Feb 2018 16:45:00 GMT</pubDate></item><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Invalid Date]]></title><description><![CDATA[<p>One thing I've forgotten to mention is how to connect to the <code>&quot;private&quot;</code> room from the client-side. You'd have this call in your client:</p>
<pre><code>import { Client } from &quot;colyseus.js&quot;;

const client = new Client(&quot;ws://...&quot;);
client.join(&quot;private&quot;, { password: &quot;someUniqueCode&quot; })
</code></pre>
]]></description><link>http://discuss.colyseus.io/post/131</link><guid isPermaLink="true">http://discuss.colyseus.io/post/131</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> said in <a href="/post/131">Joining specific rooms, playing against friends</a>:</p>
<blockquote>
<p>One thing I've forgotten to mention is how to connect to the <code>&quot;private&quot;</code> room from the client-side. You'd have this call in your client:</p>
<pre><code>import { Client } from &quot;colyseus.js&quot;;

const client = new Client(&quot;ws://...&quot;);
client.join(&quot;private&quot;, { password: &quot;someUniqueCode&quot; })
</code></pre>
</blockquote>
<p>I have a problem with private room. If same password and this room is fully connected=&gt; new Room'll be created with this same password. I don't want this, that I warning for user &quot;This room is fully, plz....&quot;</p>
<p>Do you have any solutions for this problem?</p>
]]></description><link>http://discuss.colyseus.io/post/769</link><guid isPermaLink="true">http://discuss.colyseus.io/post/769</guid><dc:creator><![CDATA[DinhNguyen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Mon, 01 Apr 2019 12:00:51 GMT]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/267">@DinhNguyen</a>,</p>
<p>The <a href="https://docs.colyseus.io/server/room/#requestjoin-options-isnew" rel="nofollow"><code>requestJoin()</code> method</a>  has a <code>isNew</code> as a second argument, you may check for it whenever requesting to join a room with a password.</p>
<p><strong>Example:</strong></p>
<pre><code>requestJoin(options, isNew) {
  if (options.password) {
    // this forces to accept only if a room already exists
    return this.password === options.password &amp;&amp; !isNew;

  } else {
    // always dissallow joining without a password
    // (you may want to change this)
    return false; 
  }
}
</code></pre>
<p>I haven't tested this code, you may need to modify it slighly</p>
]]></description><link>http://discuss.colyseus.io/post/771</link><guid isPermaLink="true">http://discuss.colyseus.io/post/771</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Mon, 01 Apr 2019 12:00:51 GMT</pubDate></item><item><title><![CDATA[Reply to Joining specific rooms, playing against friends on Invalid Date]]></title><description><![CDATA[<p>FYI, latest API supports this now. Simply pass the room handle or roomId.<br />
<a href="https://docs.colyseus.io/client/client/#join-roomnameorid-string-options-any" rel="nofollow">https://docs.colyseus.io/client/client/#join-roomnameorid-string-options-any</a></p>
]]></description><link>http://discuss.colyseus.io/post/891</link><guid isPermaLink="true">http://discuss.colyseus.io/post/891</guid><dc:creator><![CDATA[mobyjames]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>