text: Joining specific rooms, playing against friends
  - ScottyFillups last edited by ScottyFillups
  Hello!
  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 here, but it would be nice if this feature was included in Colyseus.
  If this hasn't been implemented, is there any way I can help? :)
  - endel administrator last edited by endel
  Hey @ScottyFillups,
  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:)
  You'd need to handle this case on your own, though.
  You have a couple of options, such as:
  - Letting the user set a password for the private room upon creation, and prevent clients from joining without the password on
  requestJoin.
  class MyRoom extends Room { onInit (options) { this.password = options.password; } requestJoin (options) { return (this.password && options.password == this.password); } }
  - Registering a new handler
  "private"for private rooms. Fresh clients could join only the
  "public"by default, while the
  "private"rooms could have the id shared with friends. On this setup there's a possibility that users can "hack" the JavaScript file, allowing to join the
  "private"rooms by default instead, but that's unlikely to happen.
  gameServer.register("public", MyRoom); gameServer.register("private", MyRoom);
  Hope this helps! Cheers!
  - endel administrator last edited by" })
  - DinhNguyen last edited by
  @end?
  - endel administrator last edited by endel
  Hi @DinhNguyen,
  The
  requestJoin()method has a
  isNewas a second argument, you may check for it whenever requesting to join a room with a password.
  Example:
  requestJoin(options, isNew) { if (options.password) { // this forces to accept only if a room already exists return this.password === options.password && !isNew; } else { // always dissallow joining without a password // (you may want to change this) return false; } }
  I haven't tested this code, you may need to modify it slighly
  FYI, latest API supports this now. Simply pass the room handle or roomId.