Gamehoster Browse Functions
The list a player chooses from before joining. See Browsing.
The call returns a subscription handle: set its
onChange and onError, and call cancel() to stop. There is just
one thing to browse: an instance (a live room you can drop into).
Provisional: this tracks the frontend API as it settles.
| Function | Returns | onChange receives |
|---|---|---|
Gamehoster.Browse.Instances() | subscription handle | array of Instance |
Browse.Instances takes no argument; it lists every open instance the game is running right now.
Usage
Set the handlers on the returned object; onChange fires once immediately with the current
list and again every time it changes, until you cancel().
const instances = Gamehoster.Browse.Instances()
instances.onChange = list => renderInstanceList(list)
instances.onError = err => showError(err)
// when the menu closes
instances.cancel()
The Instance object
A live room you can join. Browse.Instances yields an array of these; joining one
returns the fuller live shape (see Instance).
{
"id": "i-7f3a2c",
"phase": "waiting",
"players": 3,
"capacity": 8,
"access": "open"
}
| Field | Type | Description |
|---|---|---|
id | string | Unique id. Pass it to join this one. |
phase | string | The instance's current phase. For pong,
waiting, playing or over. |
players | number | How many players are in it right now. |
capacity | number | The most it holds. |
access | string | open to drop straight in, or
key when a password is needed to join. |
Private rooms don't appear here. A player reaches one with its key.