<?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[Question on login from second device and close first device login]]></title><description><![CDATA[<p>Hi I tried to remove the previous login client at requestJoin part by matching client Id and I can successfully remove the previous login client. But If the client is the last person in the room, the room will get disposed and new room will be created for the second login client. And this will cause a remoteroom call promised error. Is there better way for kick out first login client instead of detecting at requestJoin? Please advise please.</p>
<p>requestJoin (options) {</p>
<pre><code>console.log(&quot;request join!&quot;, options);

for(var id in this.clients)
{
  if(options.clientId == this.clients[id].id)
  {
    this.clients[id].close();
  }
}
return true;
</code></pre>
<p>}</p>
]]></description><link>http://discuss.colyseus.io/topic/145/question-on-login-from-second-device-and-close-first-device-login</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 08:37:59 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/145.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Sep 2018 12:24:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Question on login from second device and close first device login on Mon, 10 Sep 2018 12:26:46 GMT]]></title><description><![CDATA[<p>Hi I tried to remove the previous login client at requestJoin part by matching client Id and I can successfully remove the previous login client. But If the client is the last person in the room, the room will get disposed and new room will be created for the second login client. And this will cause a remoteroom call promised error. Is there better way for kick out first login client instead of detecting at requestJoin? Please advise please.</p>
<p>requestJoin (options) {</p>
<pre><code>console.log(&quot;request join!&quot;, options);

for(var id in this.clients)
{
  if(options.clientId == this.clients[id].id)
  {
    this.clients[id].close();
  }
}
return true;
</code></pre>
<p>}</p>
]]></description><link>http://discuss.colyseus.io/post/483</link><guid isPermaLink="true">http://discuss.colyseus.io/post/483</guid><dc:creator><![CDATA[Soh Sea Kiat]]></dc:creator><pubDate>Mon, 10 Sep 2018 12:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to Question on login from second device and close first device login on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/164">@soh-sea-kiat</a>,</p>
<p>You can store the user identifier on the client instance, and then search for it when the second joins.</p>
<p><strong>Example:</strong></p>
<pre><code>onJoin (client, options) {
  var alreadyJoined = this.clients.find(client =&gt; {
    return client.userId === options.userId;
  });

  if (alreadyJoined) {
    alreadyJoined.close();
  }

  client.userId = options.userId; // just an example
}
</code></pre>
<p>Keep in mind I haven't tested this code, but it should work. I'm using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find" rel="nofollow">Array.find</a> method to get the first client matching the same <code>userId</code>, which is assigned whenever the user joins the room.</p>
<p>Hope this helps! Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/484</link><guid isPermaLink="true">http://discuss.colyseus.io/post/484</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Question on login from second device and close first device login on Invalid Date]]></title><description><![CDATA[<p>Solve it. Need to check for sessionId also. Thanks for help ! cheers !</p>
]]></description><link>http://discuss.colyseus.io/post/485</link><guid isPermaLink="true">http://discuss.colyseus.io/post/485</guid><dc:creator><![CDATA[Soh Sea Kiat]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>