Skip to content
Docs
Reference

@disko-game/room

The Node room-host API, generated from the package declarations.

@disko-game/room exports the classes Room, Player and DiskoError and the types below. It runs on Node.js 22 or later, as ESM only, with a prebuilt native addon for seven platforms. The guides start at Room.launch & options.

sh

Classes

Room

A hosted room. Launch one with Room.launch. Properties are read-only and always current: they are updated before the event that reports a change is delivered. Every method returns a Promise that settles when the engine applied the command; commands on one room apply in call order.

ts
MemberDescription
permissionsroom.permissions: resolvers of the game's permissions.
actionsroom.actions: Room management player and room actions.
optionsroom.options: Room management option rows.
bansroom.bans: the room's bans.
static launch()Launches a room: validates the options, binds the WebTransport endpoint, loads the initial game into Ready, fetches the master's ticket verification key, and registers the hosting lease. Any failure rejects with a DiskoError and releases every resource. A room never appears in discovery without a loaded game.
id32 lowercase hex digits.
urlThe public WebTransport URL.
link<play>/?room=<id>, shareable.
stateLifecycle state.
gameThe loaded game and the permissions it declares.
playersConnected players, including spectators, in join order.
nameThe advertised name.
descriptionThe advertised description.
publicListed in the directory.
guestsAdmits players without an account.
locationDeclared coordinates, or null.
capacityAdmitted players.
on()Subscribes to a built-in event or a game event game:<name>. Handlers run on the main thread in subscription order. Unknown built-in names throw a TypeError.
off()Removes one subscription.
load()Replaces the game. Resolves once the new game is Ready; players stay connected and the new game starts fresh. On failure the previous game keeps running.
start()Starts a fresh game instance. Resolves when Running.
stop()Stops the game. Resolves when Ready. A faulted game recovers fresh.
pause()Holds the running game at its current boundary.
resume()Continues the paused game.
send()Sends a visible message: text from the room, or { author?, content, sound? }. Resolves with the message identity.
emit()Sends an event to the game, delivered on its next eligible turn. Resolves when queued. payload must be JSON-serializable.
setName()Replaces the advertised name.
setDescription()Replaces the advertised description; "" clears it.
setPublic()Lists or unlists the room. Direct links keep working.
setGuests()Admits or refuses new guests. Connected guests stay.
setLocation()Declares coordinates, or clears them with null.
close()Closes the room: stops accepting players and disconnects everyone with the reason, releases the directory lease, stops the engine, then emits close. Idempotent; never rejects.

DiskoError

Every rejection of the room-host API. code is stable; the message is human text that is not a stable contract.

ts
MemberDescription
codeStable error code.
problemsProblems, for game_invalid and game_build_failed.

Player

A player connected to the room, including spectators. A player object belongs to one connection: after leaving, connected is false and a returning person is a new player.

ts
MemberDescription
idStable for the connection.
accountAn opaque account id, or null for guests.
isOwnerSigned in with the account that owns the room. Guests never are.
nameResolved under the loaded game's name policy.
connectedfalse after the player left or was disconnected.
play()Asks the game to make this player a participant.
spectate()Moves this player to the spectators.
setPresentation()Sets how clients render this player's name: in the player list, the player detail view, chat and ui.playerName.
kick()Disconnects this player, showing them the reason. They may rejoin.
ban()Bans this player for the room's lifetime and disconnects them. Signed-in players are banned by account, guests by an engine-held network identity the room never sees.

Room policy

room.permissions

room.permissions: resolvers of the game's permissions.

ts
MemberDescription
resolveRegisters a resolver for one permission name, or, without a name, for every permission the loaded game declares. A named resolver takes precedence. Registering again replaces it.
removeRemoves the resolver of one name, or the catch-all without a name.
refreshMarks decisions stale so resolvers are asked again, after the room's own facts changed. Omitted fields mean every player or permission.

room.actions

room.actions: Room management player and room actions.

ts
MemberDescription
playerDefines or replaces a player action.
roomDefines or replaces a room action.
removeRemoves an action.
refreshAsks visible again after the room's facts changed.

room.options

room.options: Room management option rows.

ts
MemberDescription
toggleA label and a toggle.
choiceA label and one of a closed set of choices.
numberA label and a bounded number.
textA label and bounded text.
setSets an option's value; every viewer sees it live.
removeRemoves an option.

room.bans

room.bans: the room's bans.

ts
MemberDescription
listThe current bans.
importRestores a ban from the sealed export of this room.

Types

ChatRequestEvent

Payload of chat-request. Nothing is shown unless the room sends it.

ts
MemberDescription
idRoom-assigned request identity.
playerThe sender.
textPlain text.

CloseEvent

Payload of close.

ts
MemberDescription
reasonThe given reason, "controller_overloaded" when the event queue filled, or "engine_error" after a native engine failure.

CloseOptions

Options of Room.close.

ts
MemberDescription
reasonShown to players and reported in close. Default "closed".

DirectoryEvent

Payload of directory.

ts
MemberDescription
statusAfter "rejected" the room keeps running but is no longer advertised or joinable through the directory.
errorWhy a publication failed.

GameEventName

A game event: game:<name> from game.emit(<name>, payload).

ts

GameFaultEvent

Payload of game-fault. The room keeps serving players and chat.

ts
MemberDescription
messageThe error message.
stackThe stack, in package paths.
phase"start", "tick" or "event".

GameInfo

The loaded game.

ts
MemberDescription
reference"ns/slug@version" of a registry release, or null.
pathThe absolute path of a local game, or null.
digestblake3:<hex>: exactly what the room runs.

GameLoadedEvent

Payload of game-loaded.

ts
MemberDescription
deprecationA deprecated release's notice, or null.

Handler

An event handler. It may be async; the room never waits for it, and it never catches its errors.

ts

JsonValue

A JSON value, frozen.

ts

LoadedGame

The loaded game and the permissions it declares.

ts
MemberDescription
permissionsPermissions the game declares, in declaration order.

LoadOptions

Options of Room.load.

ts
MemberDescription
playersThe new game's name policy.

Message

A structured room message.

ts
MemberDescription
authorA connected player, or omitted for the room.
contentText, or 1-32 spans; at most 2048 bytes of text.
soundDefault "normal".

PlayerEvent

Payload of player-join and player-leave.

ts

RoomEvents

Built-in events and their payloads.

ts

RoomState

Lifecycle state of a room.

ts

StateEvent

Payload of state.

ts
MemberDescription
reason"finished", "stopped" or "fault" where it applies.

DiskoErrorCode

Stable error codes of the room-host API.

  • invalid_option: a bad launch option or setter value; the message names it. - invalid_state: a lifecycle method called in the wrong state. - invalid_message: a bad send argument. - invalid_event: a bad emit argument. - unauthorized: disko-master rejected the room id or token. - game_not_found: an unknown release, or a private release without access. - game_removed: a release that was taken down. - game_invalid: the game failed the release checks; see problems. - game_build_failed: a local project failed to build; see problems. - game_start_failed: the game script threw during top-level evaluation or exceeded its startup limits; the message includes the stack. - registry_unavailable: the registry or disko-master could not be reached, or another instance's hosting lease stayed live for leaseSeconds plus a margin while launch waited for it. - listen_failed: the address is in use or not bindable. - certificate_invalid: the certificate or key did not parse or match. - closed: the room is closed.

ts

DiskoErrorOptions

Options of the DiskoError constructor.

ts
MemberDescription
problemsRelease-check or build problems.
causeThe underlying error.

Problem

One build or validation problem, in the shape shared by the CLI, the registry and room hosts.

code is stable. message is human text that states the fix; it is not a stable contract. line and column are 1-based and present only for source positions (columns count UTF-16 code units).

ts
MemberDescription
codeStable machine-readable code, for example import_unresolved.
pathProject or package path the problem concerns.
line1-based line.
column1-based column in UTF-16 code units.
messageWhat is wrong and how to fix it.
docsThe documentation page for code.

BanOptions

Options of Player.ban.

ts
MemberDescription
reasonShown to the player, at most 256 UTF-8 bytes.

PlayerColor

Palette roles a room may give a player's name.

ts

Presentation

Room-set presentation of a player's name. null clears a field.

ts
MemberDescription
colorA client palette role, never an arbitrary color.
badgeOne short label, at most 12 characters, for example "Admin".

ActionConfirm

A confirmation before an action runs: true asks to confirm, and { reason: true } also offers one optional text field, such as "Reason".

ts

ActionRefresh

Options of room.actions.refresh.

ts
MemberDescription
viewerOnly this viewer; omitted, every viewer.

BanEntry

An opaque ban entry. It never contains an address or an account.

ts
MemberDescription
idIdentity for this room's lifetime.
kind"account" or "guest".
nameThe player's name at ban time.
reasonThe ban reason.
sealedA sealed export: store it and pass it to room.bans.import after a restart of the same room to restore the ban.
lift()Lifts this ban.

ChoiceOptionDefinition

A choice option row.

ts
MemberDescription
choices1-32 distinct choices.

NumberOptionDefinition

A number option row.

ts
MemberDescription
minInclusive minimum.
maxInclusive maximum.
stepOptional positive step from the minimum.

OptionChoice

A choice of a choice option.

ts
MemberDescription
valueSubmitted value, 1-32 UTF-8 bytes.
labelDisplayed label.

OptionContext

What visible and editable of an option receive.

ts
MemberDescription
viewerThe player viewing the Room management modal.

OptionDefinition

Fields every option row shares.

ts
MemberDescription
labelRow label, 1-48 UTF-8 bytes.
valueThe current value.
visibleWhich viewers see the row. Omitted: everyone.
editableWhich viewers may change the value. Omitted: nobody; a visible row that is not editable shows its value read-only.
changeAccepts a viewer's change after visible and editable are checked again. Throwing rejects it: the row keeps its value and the viewer sees the error message. Every viewer sees an accepted value live.

PermissionDeclaration

A permission a game declares.

ts
MemberDescription
nameThe game's name for it, for example "manage-match".
labelA human label for room owners.
defaultThe game's decision when the room makes none.

PermissionRequest

What a permission resolver receives.

ts
MemberDescription
playerThe player the decision is for.
permissionThe permission being decided.
gameEvery permission the loaded game declares.

PermissionResolver

Decides one permission for one player: true grants it, false denies it, and undefined keeps the game's default. It may be async. Errors are not caught (they reach Node's uncaughtException), and the game's default applies to that decision.

ts

PlayerActionContext

What visible of a player action receives.

ts
MemberDescription
viewerThe player viewing the Room management modal.
targetThe player whose detail view lists the action.

PlayerActionDefinition

A player action, shown in a player's detail view.

ts
MemberDescription
labelButton label, 1-48 UTF-8 bytes.
confirmOptional confirmation.
visibleWhich viewers see the action for which targets. Omitted: everyone.
runRuns the action after visible is checked again. Throwing rejects it, and the error message is shown to the viewer.

RoomActionContext

What visible of a room action receives.

ts
MemberDescription
viewerThe player viewing the Room management modal.

RoomActionDefinition

A room action, shown in the Actions section.

ts
MemberDescription
labelButton label, 1-48 UTF-8 bytes.
confirmOptional confirmation.
visibleWhich viewers see the action. Omitted: everyone.
runRuns the action after visible is checked again. Throwing rejects it, and the error message is shown to the viewer.

TextOptionDefinition

A text option row.

ts
MemberDescription
maxLengthMaximum UTF-8 bytes, at most 128.
secretThe value is never delivered to viewers.

MessageSound

Whole-message sound category the client plays.

ts

MessageSpan

One styled substring of a room message.

ts
MemberDescription
textNon-empty text.
color#rrggbb or #rrggbbaa.
weightSuggested weight. Default "normal".
styleSuggested style. Default "normal".

Certificate

A certificate identity as PEM strings, not file paths.

ts
MemberDescription
certificatePemThe certificate chain, leaf first.
privateKeyPemThe PKCS#8 private key of the leaf certificate.

Endpoints

Base URLs of the disko services. Local development passes *.localhost.

ts
MemberDescription
apidisko-master API host. Default https://api.disko.ooo.
registryRegistry host. Default https://registry.disko.ooo.
playWeb client, for room links. Default https://play.disko.ooo.

GameSource

A game to load: a release reference, or a local directory or .tgz.

ts

HostOptions

The launch options a host function receives from disko dev or its own entry point: credentials, the game, and the network options. The host function passes them through to Room.launch.

ts

LaunchOptions

Options of Room.launch. Unknown keys reject with invalid_option.

ts
MemberDescription
id32 lowercase hex digits: a room identity from the Creator Portal, or a test room.
tokenThe room's hosting token. It is never logged, never exposed on the Room, and sent only to disko-master.
name1-96 UTF-8 bytes, not blank, no control characters.
game"ns/slug@version", or { path } of a local directory or .tgz.
playersThe name policy of the initial game.
descriptionAt most 1024 UTF-8 bytes. Default "".
publicListed in the directory. Default true. Test rooms are never listed.
guestsAdmit players without an account. Default true.
locationDeclared coordinates, or null. Default null.
password1-4096 UTF-8 bytes, or null for no password. Default null.
capacityAdmitted players, 1-65535. Default 64.
listenUDP/HTTP3 bind address. Default "0.0.0.0:4433". Only when omitted, a taken port falls back to the next free one up to 4532. An explicit port is used exactly; port 0 picks a random free port.
publicUrlThe WebTransport URL players connect to. Derived when omitted: from the bound address when listen names a host, otherwise from the address disko-master observes for this host.
transportPathWebTransport request path. Default "/room".
certificateA certificate chain and key. Without it the room uses a self-signed ECDSA P-256 certificate valid for 13 days, rotated every 6 days.
endpointsService base URLs. Default: the production hosts.
cacheDirThe release cache, keyed by digest. Default: the OS cache directory + /disko-game/releases.
leaseSecondsDirectory lease duration, 5-300 seconds. Default 30.
loggingNative engine logging.
limitsResource limit overrides.

Limits

Resource limits; omitted fields keep the server defaults.

ts
MemberDescription
pendingHandshakesConnections allowed while admission is pending. Default 64.
streamBootstrapTimeoutMsDeadline for a player's first control stream. Default 5000.
mailboxRoom mailbox entries. Default 256.
inboundQueueFramesDecoded frames staged per player. Default 128.
inboundFramesPerSecondSustained frames per second per player. Default 240.
inboundFrameBurstFrame burst per player. Default 480.
resumeRetainedInterrupted sessions kept for resume. Default 64.
resumeGraceMsResume window. Default 15000.
checkpointChunkBytesCheckpoint chunk payload bytes. Default 16384.
eventQueueEvents waiting for the main thread. When full, chat requests get a retryable backpressure answer and any other event closes the room with controller_overloaded. Default 4096.

Location

Declared coordinates, used only for directory distance sorting.

ts
MemberDescription
latitudeDegrees, within ±90.
longitudeDegrees, within ±180.

LoggingOptions

Native engine logging.

ts
MemberDescription
filterA tracing filter. disko names every engine target. Default "disko=info". Logging is process-wide: the first room to launch installs it.
format"pretty" (the default) or "json". Records go to stderr.

PlayersOptions

How a game names players.

ts
MemberDescription
name"display" (the default) uses the account's display name, or a guest's chosen name. "username" uses the verified username; guests keep their chosen name.