Creating
Whether a player can open their own instance (and what kind)
is decided by the game's gamehoster-game-create
setting. The generated client exposes the Gamehoster.Create functions to match: with
none they aren't available at all, and otherwise a player can make a new room of the allowed
access type.
What the setting allows
Game's create | What the front end may do |
|---|---|
none | Nothing. Gamehoster.Create is not offered; players
only ever join existing instances. |
public | Create a room that is listed in Browse for anyone to join. |
password | Create a listed room, but set a password others must supply to get in. |
private | Create an unlisted room, reached only by the invite it hands back. |
The client only ever offers the modes the game permits, so a player can't open a kind of room the definition didn't allow.
Opening a room
Call Gamehoster.Create with any details the mode needs: a password
for password. On success you're placed into the new instance just as if you had
joined one, and it's live for others to find (or reach by
invite) straight away.
const created = Gamehoster.Create()
created.onSuccess = (instance) => enter(instance)
created.onError = (error) => showError(error) // not allowed, or bad details
For a password room, pass the password the joiner will need; for private, the
result carries the invite the player can share.