<?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[限制 &#x2F; 禁止 客户端创建房间]]></title><description><![CDATA[<ul>
<li>用密码限制创建房间</li>
</ul>
<pre><code>onCreate (options: any) {
    if (options.secret !== &quot;MY-SECRET-VALUE&quot;) {
        throw new Error(&quot;unauthorized&quot;);
    }
}
</code></pre>
<ul>
<li>限制相同 id 的房间创建</li>
</ul>
<pre><code>gameServer
  .define('my-room', MyRoom)
  .filterBy(['id'])
  .maxInstances(1);
</code></pre>
<ul>
<li>固定数量的房间创建好之后, 隐藏服务器 API</li>
</ul>
<pre><code>const gameServer = new Server();
const tempServer = gameServer as any; // force access to private property by casting to any
tempServer.exposedMethods = []; // override property with empty array to not expose those methods anymore
gameServer.listen(port);
</code></pre>
<ul>
<li>服务端限制房间创建频率<br />
<a href="https://docs.colyseus.io/colyseus/how-to/rate-limit/" rel="nofollow">https://docs.colyseus.io/colyseus/how-to/rate-limit/</a></li>
</ul>
]]></description><link>http://discuss.colyseus.io/topic/734/限制-禁止-客户端创建房间</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 15:43:22 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/734.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Sep 2022 09:51:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 限制 &#x2F; 禁止 客户端创建房间 on Fri, 30 Sep 2022 09:32:56 GMT]]></title><description><![CDATA[<ul>
<li>用密码限制创建房间</li>
</ul>
<pre><code>onCreate (options: any) {
    if (options.secret !== &quot;MY-SECRET-VALUE&quot;) {
        throw new Error(&quot;unauthorized&quot;);
    }
}
</code></pre>
<ul>
<li>限制相同 id 的房间创建</li>
</ul>
<pre><code>gameServer
  .define('my-room', MyRoom)
  .filterBy(['id'])
  .maxInstances(1);
</code></pre>
<ul>
<li>固定数量的房间创建好之后, 隐藏服务器 API</li>
</ul>
<pre><code>const gameServer = new Server();
const tempServer = gameServer as any; // force access to private property by casting to any
tempServer.exposedMethods = []; // override property with empty array to not expose those methods anymore
gameServer.listen(port);
</code></pre>
<ul>
<li>服务端限制房间创建频率<br />
<a href="https://docs.colyseus.io/colyseus/how-to/rate-limit/" rel="nofollow">https://docs.colyseus.io/colyseus/how-to/rate-limit/</a></li>
</ul>
]]></description><link>http://discuss.colyseus.io/post/2096</link><guid isPermaLink="true">http://discuss.colyseus.io/post/2096</guid><dc:creator><![CDATA[COCO]]></dc:creator><pubDate>Fri, 30 Sep 2022 09:32:56 GMT</pubDate></item></channel></rss>