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: http://colyseus.io/docs/client-room/#properties)
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!